Makes http request cached for tests
This commit is contained in:
13
data_test.go
13
data_test.go
@@ -9,10 +9,16 @@ import (
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"time"
|
||||
|
||||
"github.com/gregjones/httpcache"
|
||||
"github.com/gregjones/httpcache/diskcache"
|
||||
"github.com/peterbourgon/diskv"
|
||||
)
|
||||
|
||||
var albumsDataTest []Album
|
||||
|
||||
var testGetter HTTPGetter
|
||||
|
||||
// StripNonCsvField strips all the fields which are not in the Csv
|
||||
func StripNonCsvField(a Album) Album {
|
||||
return Album{
|
||||
@@ -89,4 +95,11 @@ func init() {
|
||||
if err = dec.Decode(&albumsDataTest); err != nil {
|
||||
panic(fmt.Sprintf("Could not parse '%s': %s", albumsPath, err))
|
||||
}
|
||||
|
||||
dv := diskv.New(diskv.Options{
|
||||
BasePath: filepath.Join("testdata", "web-cache"),
|
||||
CacheSizeMax: 100 * 1024 * 1024, // 100MB
|
||||
})
|
||||
testGetter = httpcache.NewTransport(diskcache.NewWithDiskv(dv)).Client()
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user