diff --git a/mongodb/mongodb_test.go b/mongodb/mongodb_test.go index ac5c61c9..b3f8db41 100644 --- a/mongodb/mongodb_test.go +++ b/mongodb/mongodb_test.go @@ -52,6 +52,7 @@ func Test_MongoDB_Set(t *testing.T) { testStore, err := newTestStore(t) require.NoError(t, err) + defer testStore.Close() err = testStore.Set(key, val, 0) require.NoError(t, err) @@ -65,6 +66,7 @@ func Test_MongoDB_Set_Override(t *testing.T) { testStore, err := newTestStore(t) require.NoError(t, err) + defer testStore.Close() err = testStore.Set(key, val, 0) require.NoError(t, err) @@ -81,6 +83,7 @@ func Test_MongoDB_Get(t *testing.T) { testStore, err := newTestStore(t) require.NoError(t, err) + defer testStore.Close() err = testStore.Set(key, val, 0) require.NoError(t, err) @@ -99,6 +102,7 @@ func Test_MongoDB_Set_Expiration(t *testing.T) { testStore, err := newTestStore(t) require.NoError(t, err) + defer testStore.Close() err = testStore.Set(key, val, exp) require.NoError(t, err) @@ -111,6 +115,7 @@ func Test_MongoDB_Get_Expired(t *testing.T) { testStore, err := newTestStore(t) require.NoError(t, err) + defer testStore.Close() result, err := testStore.Get(key) require.NoError(t, err) @@ -120,6 +125,7 @@ func Test_MongoDB_Get_Expired(t *testing.T) { func Test_MongoDB_Get_NotExist(t *testing.T) { testStore, err := newTestStore(t) require.NoError(t, err) + defer testStore.Close() result, err := testStore.Get("notexist") require.NoError(t, err) @@ -134,6 +140,7 @@ func Test_MongoDB_Delete(t *testing.T) { testStore, err := newTestStore(t) require.NoError(t, err) + defer testStore.Close() err = testStore.Set(key, val, 0) require.NoError(t, err) @@ -151,6 +158,7 @@ func Test_MongoDB_Reset(t *testing.T) { testStore, err := newTestStore(t) require.NoError(t, err) + defer testStore.Close() err = testStore.Set("john1", val, 0) require.NoError(t, err) @@ -173,6 +181,7 @@ func Test_MongoDB_Reset(t *testing.T) { func Test_MongoDB_Close(t *testing.T) { testStore, err := newTestStore(t) require.NoError(t, err) + defer testStore.Close() require.Nil(t, testStore.Close()) } @@ -180,6 +189,7 @@ func Test_MongoDB_Close(t *testing.T) { func Test_MongoDB_Conn(t *testing.T) { testStore, err := newTestStore(t) require.NoError(t, err) + defer testStore.Close() require.True(t, testStore.Conn() != nil) } @@ -187,6 +197,7 @@ func Test_MongoDB_Conn(t *testing.T) { func Benchmark_MongoDB_Set(b *testing.B) { testStore, err := newTestStore(b) require.NoError(b, err) + defer testStore.Close() b.ReportAllocs() b.ResetTimer() @@ -201,6 +212,7 @@ func Benchmark_MongoDB_Set(b *testing.B) { func Benchmark_MongoDB_Get(b *testing.B) { testStore, err := newTestStore(b) require.NoError(b, err) + defer testStore.Close() err = testStore.Set("john", []byte("doe"), 0) require.NoError(b, err) @@ -218,6 +230,7 @@ func Benchmark_MongoDB_Get(b *testing.B) { func Benchmark_MongoDB_SetAndDelete(b *testing.B) { testStore, err := newTestStore(b) require.NoError(b, err) + defer testStore.Close() b.ReportAllocs() b.ResetTimer() diff --git a/mssql/mssql_test.go b/mssql/mssql_test.go index 3a8e87af..780ce9a1 100644 --- a/mssql/mssql_test.go +++ b/mssql/mssql_test.go @@ -58,6 +58,7 @@ func Test_MSSQL_Set(t *testing.T) { testStore, err := newTestStore(t) require.NoError(t, err) + defer testStore.Close() err = testStore.Set(key, val, 0) require.NoError(t, err) @@ -71,6 +72,7 @@ func Test_MSSQL_Set_Override(t *testing.T) { testStore, err := newTestStore(t) require.NoError(t, err) + defer testStore.Close() err = testStore.Set(key, val, 0) require.NoError(t, err) @@ -87,6 +89,7 @@ func Test_MSSQL_Get(t *testing.T) { testStore, err := newTestStore(t) require.NoError(t, err) + defer testStore.Close() err = testStore.Set(key, val, 0) require.NoError(t, err) @@ -105,6 +108,7 @@ func Test_MSSQL_Set_Expiration(t *testing.T) { testStore, err := newTestStore(t) require.NoError(t, err) + defer testStore.Close() err = testStore.Set(key, val, exp) require.NoError(t, err) @@ -117,6 +121,7 @@ func Test_MSSQL_Get_Expired(t *testing.T) { testStore, err := newTestStore(t) require.NoError(t, err) + defer testStore.Close() result, err := testStore.Get(key) require.NoError(t, err) @@ -126,6 +131,7 @@ func Test_MSSQL_Get_Expired(t *testing.T) { func Test_MSSQL_Get_NotExist(t *testing.T) { testStore, err := newTestStore(t) require.NoError(t, err) + defer testStore.Close() result, err := testStore.Get("notexist") require.NoError(t, err) @@ -140,6 +146,7 @@ func Test_MSSQL_Delete(t *testing.T) { testStore, err := newTestStore(t) require.NoError(t, err) + defer testStore.Close() err = testStore.Set(key, val, 0) require.NoError(t, err) @@ -157,6 +164,7 @@ func Test_MSSQL_Reset(t *testing.T) { testStore, err := newTestStore(t) require.NoError(t, err) + defer testStore.Close() err = testStore.Set("john1", val, 0) require.NoError(t, err) @@ -181,6 +189,7 @@ func Test_MSSQL_GC(t *testing.T) { testStore, err := newTestStore(t) require.NoError(t, err) + defer testStore.Close() // This key should expire err = testStore.Set("john", testVal, time.Nanosecond) @@ -206,6 +215,7 @@ func Test_MSSQL_Non_UTF8(t *testing.T) { testStore, err := newTestStore(t) require.NoError(t, err) + defer testStore.Close() err = testStore.Set("0xF6", val, 0) require.NoError(t, err) @@ -233,6 +243,7 @@ func Test_SslRequiredMode(t *testing.T) { func Test_MSSQL_Close(t *testing.T) { testStore, err := newTestStore(t) require.NoError(t, err) + defer testStore.Close() require.Nil(t, testStore.Close()) } @@ -240,6 +251,7 @@ func Test_MSSQL_Close(t *testing.T) { func Test_MSSQL_Conn(t *testing.T) { testStore, err := newTestStore(t) require.NoError(t, err) + defer testStore.Close() require.True(t, testStore.Conn() != nil) } @@ -247,6 +259,7 @@ func Test_MSSQL_Conn(t *testing.T) { func Benchmark_MSSQL_Set(b *testing.B) { testStore, err := newTestStore(b) require.NoError(b, err) + defer testStore.Close() b.ReportAllocs() b.ResetTimer() @@ -261,6 +274,7 @@ func Benchmark_MSSQL_Set(b *testing.B) { func Benchmark_MSSQL_Get(b *testing.B) { testStore, err := newTestStore(b) require.NoError(b, err) + defer testStore.Close() err = testStore.Set("john", []byte("doe"), 0) require.NoError(b, err) @@ -278,6 +292,7 @@ func Benchmark_MSSQL_Get(b *testing.B) { func Benchmark_MSSQL_SetAndDelete(b *testing.B) { testStore, err := newTestStore(b) require.NoError(b, err) + defer testStore.Close() b.ReportAllocs() b.ResetTimer() diff --git a/mysql/mysql_test.go b/mysql/mysql_test.go index 393fc49e..895dd53e 100644 --- a/mysql/mysql_test.go +++ b/mysql/mysql_test.go @@ -59,6 +59,7 @@ func mustStartMySQL(t testing.TB) *mysql.MySQLContainer { func Test_MYSQL_New(t *testing.T) { testStore, err := newTestStore(t) require.NoError(t, err) + defer testStore.Close() require.True(t, testStore.db != nil) require.NoError(t, testStore.Close()) @@ -86,6 +87,7 @@ func Test_MYSQL_Set(t *testing.T) { testStore, err := newTestStore(t) require.NoError(t, err) + defer testStore.Close() err = testStore.Set(key, val, 0) require.NoError(t, err) @@ -99,6 +101,7 @@ func Test_MYSQL_Set_Override(t *testing.T) { testStore, err := newTestStore(t) require.NoError(t, err) + defer testStore.Close() err = testStore.Set(key, val, 0) require.NoError(t, err) @@ -115,6 +118,7 @@ func Test_MYSQL_Get(t *testing.T) { testStore, err := newTestStore(t) require.NoError(t, err) + defer testStore.Close() err = testStore.Set(key, val, 0) require.NoError(t, err) @@ -133,6 +137,7 @@ func Test_MYSQL_Set_Expiration(t *testing.T) { testStore, err := newTestStore(t) require.NoError(t, err) + defer testStore.Close() err = testStore.Set(key, val, exp) require.NoError(t, err) @@ -145,6 +150,7 @@ func Test_MYSQL_Get_Expired(t *testing.T) { testStore, err := newTestStore(t) require.NoError(t, err) + defer testStore.Close() result, err := testStore.Get(key) require.NoError(t, err) @@ -154,6 +160,7 @@ func Test_MYSQL_Get_Expired(t *testing.T) { func Test_MYSQL_Get_NotExist(t *testing.T) { testStore, err := newTestStore(t) require.NoError(t, err) + defer testStore.Close() result, err := testStore.Get("notexist") require.NoError(t, err) @@ -168,6 +175,7 @@ func Test_MYSQL_Delete(t *testing.T) { testStore, err := newTestStore(t) require.NoError(t, err) + defer testStore.Close() err = testStore.Set(key, val, 0) require.NoError(t, err) @@ -185,6 +193,7 @@ func Test_MYSQL_Reset(t *testing.T) { testStore, err := newTestStore(t) require.NoError(t, err) + defer testStore.Close() err = testStore.Set("john1", val, 0) require.NoError(t, err) @@ -210,6 +219,7 @@ func Test_MYSQL_GC(t *testing.T) { // This key should expire testStore, err := newTestStore(t) require.NoError(t, err) + defer testStore.Close() err = testStore.Set("john", testVal, time.Nanosecond) require.NoError(t, err) @@ -234,6 +244,7 @@ func Test_MYSQL_Non_UTF8(t *testing.T) { testStore, err := newTestStore(t) require.NoError(t, err) + defer testStore.Close() err = testStore.Set("0xF6", val, 0) require.NoError(t, err) @@ -246,6 +257,7 @@ func Test_MYSQL_Non_UTF8(t *testing.T) { func Test_MYSQL_Close(t *testing.T) { testStore, err := newTestStore(t) require.NoError(t, err) + defer testStore.Close() require.Nil(t, testStore.Close()) } @@ -253,6 +265,7 @@ func Test_MYSQL_Close(t *testing.T) { func Test_MYSQL_Conn(t *testing.T) { testStore, err := newTestStore(t) require.NoError(t, err) + defer testStore.Close() require.True(t, testStore.Conn() != nil) } @@ -260,6 +273,7 @@ func Test_MYSQL_Conn(t *testing.T) { func Benchmark_MYSQL_Set(b *testing.B) { testStore, err := newTestStore(b) require.NoError(b, err) + defer testStore.Close() b.ReportAllocs() b.ResetTimer() @@ -274,6 +288,7 @@ func Benchmark_MYSQL_Set(b *testing.B) { func Benchmark_MYSQL_Get(b *testing.B) { testStore, err := newTestStore(b) require.NoError(b, err) + defer testStore.Close() err = testStore.Set("john", []byte("doe"), 0) require.NoError(b, err) @@ -291,6 +306,7 @@ func Benchmark_MYSQL_Get(b *testing.B) { func Benchmark_MYSQL_SetAndDelete(b *testing.B) { testStore, err := newTestStore(b) require.NoError(b, err) + defer testStore.Close() b.ReportAllocs() b.ResetTimer() diff --git a/postgres/postgres_test.go b/postgres/postgres_test.go index 7d86808a..94cc72a5 100644 --- a/postgres/postgres_test.go +++ b/postgres/postgres_test.go @@ -63,6 +63,7 @@ func Test_Postgres_Set(t *testing.T) { testStore, err := newTestStore(t) require.NoError(t, err) + defer testStore.Close() err = testStore.Set(key, val, 0) require.NoError(t, err) @@ -76,6 +77,7 @@ func Test_Postgres_Set_Override(t *testing.T) { testStore, err := newTestStore(t) require.NoError(t, err) + defer testStore.Close() err = testStore.Set(key, val, 0) require.NoError(t, err) @@ -92,6 +94,7 @@ func Test_Postgres_Get(t *testing.T) { testStore, err := newTestStore(t) require.NoError(t, err) + defer testStore.Close() err = testStore.Set(key, val, 0) require.NoError(t, err) @@ -110,6 +113,7 @@ func Test_Postgres_Set_Expiration(t *testing.T) { testStore, err := newTestStore(t) require.NoError(t, err) + defer testStore.Close() err = testStore.Set(key, val, exp) require.NoError(t, err) @@ -122,6 +126,7 @@ func Test_Postgres_Get_Expired(t *testing.T) { testStore, err := newTestStore(t) require.NoError(t, err) + defer testStore.Close() result, err := testStore.Get(key) require.NoError(t, err) @@ -131,6 +136,7 @@ func Test_Postgres_Get_Expired(t *testing.T) { func Test_Postgres_Get_NotExist(t *testing.T) { testStore, err := newTestStore(t) require.NoError(t, err) + defer testStore.Close() result, err := testStore.Get("notexist") require.NoError(t, err) @@ -145,6 +151,7 @@ func Test_Postgres_Delete(t *testing.T) { testStore, err := newTestStore(t) require.NoError(t, err) + defer testStore.Close() err = testStore.Set(key, val, 0) require.NoError(t, err) @@ -162,6 +169,7 @@ func Test_Postgres_Reset(t *testing.T) { testStore, err := newTestStore(t) require.NoError(t, err) + defer testStore.Close() err = testStore.Set("john1", val, 0) require.NoError(t, err) @@ -186,6 +194,7 @@ func Test_Postgres_GC(t *testing.T) { testStore, err := newTestStore(t) require.NoError(t, err) + defer testStore.Close() // This key should expire err = testStore.Set("john", testVal, time.Nanosecond) @@ -211,6 +220,7 @@ func Test_Postgres_Non_UTF8(t *testing.T) { testStore, err := newTestStore(t) require.NoError(t, err) + defer testStore.Close() err = testStore.Set("0xF6", val, 0) require.NoError(t, err) @@ -234,6 +244,7 @@ func Test_SslRequiredMode(t *testing.T) { func Test_Postgres_Conn(t *testing.T) { testStore, err := newTestStore(t) require.NoError(t, err) + defer testStore.Close() require.True(t, testStore.Conn() != nil) } @@ -241,6 +252,7 @@ func Test_Postgres_Conn(t *testing.T) { func Test_Postgres_Close(t *testing.T) { testStore, err := newTestStore(t) require.NoError(t, err) + defer testStore.Close() require.Nil(t, testStore.Close()) } @@ -248,6 +260,7 @@ func Test_Postgres_Close(t *testing.T) { func Benchmark_Postgres_Set(b *testing.B) { testStore, err := newTestStore(b) require.NoError(b, err) + defer testStore.Close() b.ReportAllocs() b.ResetTimer() @@ -262,6 +275,7 @@ func Benchmark_Postgres_Set(b *testing.B) { func Benchmark_Postgres_Get(b *testing.B) { testStore, err := newTestStore(b) require.NoError(b, err) + defer testStore.Close() err = testStore.Set("john", []byte("doe"), 0) require.NoError(b, err) @@ -279,6 +293,7 @@ func Benchmark_Postgres_Get(b *testing.B) { func Benchmark_Postgres_SetAndDelete(b *testing.B) { testStore, err := newTestStore(b) require.NoError(b, err) + defer testStore.Close() b.ReportAllocs() b.ResetTimer()