From c4b49a2d5214af56ca701fd97a21c61958459941 Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Mon, 14 Feb 2022 15:42:57 +0300 Subject: [PATCH] storage: deduplicate storage closing in tests --- pkg/core/storage/storeandbatch_test.go | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/pkg/core/storage/storeandbatch_test.go b/pkg/core/storage/storeandbatch_test.go index 38bf5f282..6b8d7c102 100644 --- a/pkg/core/storage/storeandbatch_test.go +++ b/pkg/core/storage/storeandbatch_test.go @@ -19,10 +19,6 @@ type dbSetup struct { type dbTestFunction func(*testing.T, Store) -func testStoreClose(t *testing.T, s Store) { - require.NoError(t, s.Close()) -} - func testStorePutAndGet(t *testing.T, s Store) { key := []byte("foo") value := []byte("bar") @@ -32,8 +28,6 @@ func testStorePutAndGet(t *testing.T, s Store) { result, err := s.Get(key) assert.Nil(t, err) require.Equal(t, value, result) - - require.NoError(t, s.Close()) } func testStoreGetNonExistent(t *testing.T, s Store) { @@ -41,7 +35,6 @@ func testStoreGetNonExistent(t *testing.T, s Store) { _, err := s.Get(key) assert.Equal(t, err, ErrKeyNotFound) - require.NoError(t, s.Close()) } func testStorePutBatch(t *testing.T, s Store) { @@ -63,7 +56,6 @@ func testStorePutBatch(t *testing.T, s Store) { assert.Nil(t, err) require.Equal(t, value, newVal) assert.Equal(t, value, newVal) - require.NoError(t, s.Close()) } func testStoreSeek(t *testing.T, s Store) { @@ -338,15 +330,12 @@ func testStoreSeek(t *testing.T, s Store) { }) }) }) - - require.NoError(t, s.Close()) } func testStoreDeleteNonExistent(t *testing.T, s Store) { key := []byte("sparse") assert.NoError(t, s.Delete(key)) - require.NoError(t, s.Close()) } func testStorePutAndDelete(t *testing.T, s Store) { @@ -365,8 +354,6 @@ func testStorePutAndDelete(t *testing.T, s Store) { // Double delete. err = s.Delete(key) assert.Nil(t, err) - - require.NoError(t, s.Close()) } func testStorePutBatchWithDelete(t *testing.T, s Store) { @@ -435,7 +422,6 @@ func testStorePutBatchWithDelete(t *testing.T, s Store) { assert.Equal(t, ErrKeyNotFound, err, "%s:%s", k, v) } } - require.NoError(t, s.Close()) } func testStoreSeekGC(t *testing.T, s Store) { @@ -480,7 +466,7 @@ func TestAllDBs(t *testing.T) { {"MemCached", newMemCachedStoreForTesting}, {"Memory", newMemoryStoreForTesting}, } - var tests = []dbTestFunction{testStoreClose, testStorePutAndGet, + var tests = []dbTestFunction{testStorePutAndGet, testStoreGetNonExistent, testStorePutBatch, testStoreSeek, testStoreDeleteNonExistent, testStorePutAndDelete, testStorePutBatchWithDelete, testStoreSeekGC} @@ -492,6 +478,7 @@ func TestAllDBs(t *testing.T) { } fname := runtime.FuncForPC(reflect.ValueOf(test).Pointer()).Name() t.Run(db.name+"/"+fname, twrapper) + require.NoError(t, s.Close()) } } }