mirror of https://github.com/containers/image.git
Simplify blobifocache/internal/test.GenericCache
We no longer need a cleanup callback. Signed-off-by: Miloslav Trmač <mitr@redhat.com>
This commit is contained in:
parent
9a9904944d
commit
a310b13598
|
|
@ -10,13 +10,13 @@ import (
|
|||
|
||||
var _ blobinfocache.BlobInfoCache2 = &cache{}
|
||||
|
||||
func newTestCache(t *testing.T) (blobinfocache.BlobInfoCache2, func(t *testing.T)) {
|
||||
func newTestCache(t *testing.T) blobinfocache.BlobInfoCache2 {
|
||||
// We need a separate temporary directory here, because bolt.Open(…, &bolt.Options{Readonly:true}) can't deal with
|
||||
// an existing but empty file, and incorrectly fails without releasing the lock - which in turn causes
|
||||
// any future writes to hang. Creating a temporary directory allows us to use a path to a
|
||||
// non-existent file, thus replicating the expected conditions for creating a new DB.
|
||||
dir := t.TempDir()
|
||||
return new2(filepath.Join(dir, "db")), func(t *testing.T) {}
|
||||
return new2(filepath.Join(dir, "db"))
|
||||
}
|
||||
|
||||
func TestNew(t *testing.T) {
|
||||
|
|
|
|||
|
|
@ -24,8 +24,8 @@ const (
|
|||
)
|
||||
|
||||
// GenericCache runs an implementation-independent set of tests, given a
|
||||
// newTestCache, which can be called repeatedly and always returns a (cache, cleanup callback) pair
|
||||
func GenericCache(t *testing.T, newTestCache func(t *testing.T) (blobinfocache.BlobInfoCache2, func(t *testing.T))) {
|
||||
// newTestCache, which can be called repeatedly and always returns a fresh cache instance
|
||||
func GenericCache(t *testing.T, newTestCache func(t *testing.T) blobinfocache.BlobInfoCache2) {
|
||||
for _, s := range []struct {
|
||||
name string
|
||||
fn func(t *testing.T, cache blobinfocache.BlobInfoCache2)
|
||||
|
|
@ -37,8 +37,7 @@ func GenericCache(t *testing.T, newTestCache func(t *testing.T) (blobinfocache.B
|
|||
{"CandidateLocations2", testGenericCandidateLocations2},
|
||||
} {
|
||||
t.Run(s.name, func(t *testing.T) {
|
||||
cache, cleanup := newTestCache(t)
|
||||
defer cleanup(t)
|
||||
cache := newTestCache(t)
|
||||
s.fn(t, cache)
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,8 +9,8 @@ import (
|
|||
|
||||
var _ blobinfocache.BlobInfoCache2 = &cache{}
|
||||
|
||||
func newTestCache(t *testing.T) (blobinfocache.BlobInfoCache2, func(t *testing.T)) {
|
||||
return new2(), func(t *testing.T) {}
|
||||
func newTestCache(t *testing.T) blobinfocache.BlobInfoCache2 {
|
||||
return new2()
|
||||
}
|
||||
|
||||
func TestNew(t *testing.T) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue