github.com/fawick/restic@v0.1.1-0.20171126184616-c02923fbfc79/internal/cache/testing.go (about) 1 package cache 2 3 import ( 4 "testing" 5 6 "github.com/restic/restic/internal/restic" 7 "github.com/restic/restic/internal/test" 8 ) 9 10 // TestNewCache returns a cache in a temporary directory which is removed when 11 // cleanup is called. 12 func TestNewCache(t testing.TB) (*Cache, func()) { 13 dir, cleanup := test.TempDir(t) 14 t.Logf("created new cache at %v", dir) 15 cache, err := New(restic.NewRandomID().String(), dir) 16 if err != nil { 17 t.Fatal(err) 18 } 19 return cache, cleanup 20 }