Adds tests for AlbumDatabase

This commit is contained in:
2016-01-21 19:34:35 +01:00
parent ef458eaaea
commit 40e1e55215
4 changed files with 60 additions and 2 deletions

View File

@@ -5,6 +5,7 @@ import (
"encoding/json"
"fmt"
"io"
"log"
"os"
"path/filepath"
"regexp"
@@ -83,6 +84,7 @@ func GetCsvData() *bytes.Buffer {
}
func init() {
start := time.Now()
albumsPath := filepath.Join("testdata", "albums.json")
f, err := os.Open(albumsPath)
if err != nil {
@@ -95,10 +97,12 @@ func init() {
panic(fmt.Sprintf("Could not parse '%s': %s", albumsPath, err))
}
log.Printf("loaded test data in %s", time.Since(start))
start = time.Now()
dv := diskv.New(diskv.Options{
BasePath: filepath.Join("testdata", "web-cache"),
CacheSizeMax: 100 * 1024 * 1024, // 100MB
})
testGetter = httpcache.NewTransport(diskcache.NewWithDiskv(dv)).Client()
log.Printf("loaded httpcache in %s", time.Since(start))
}