Skip to content

Commit

Permalink
chore: close store
Browse files Browse the repository at this point in the history
  • Loading branch information
mdelapenya committed Sep 18, 2024
1 parent 75c8525 commit 1bb4d92
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 0 deletions.
13 changes: 13 additions & 0 deletions mongodb/mongodb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -173,20 +181,23 @@ 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())
}

func Test_MongoDB_Conn(t *testing.T) {
testStore, err := newTestStore(t)
require.NoError(t, err)
defer testStore.Close()

require.True(t, testStore.Conn() != nil)
}

func Benchmark_MongoDB_Set(b *testing.B) {
testStore, err := newTestStore(b)
require.NoError(b, err)
defer testStore.Close()

b.ReportAllocs()
b.ResetTimer()
Expand All @@ -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)
Expand All @@ -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()
Expand Down
15 changes: 15 additions & 0 deletions mssql/mssql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -233,20 +243,23 @@ 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())
}

func Test_MSSQL_Conn(t *testing.T) {
testStore, err := newTestStore(t)
require.NoError(t, err)
defer testStore.Close()

require.True(t, testStore.Conn() != nil)
}

func Benchmark_MSSQL_Set(b *testing.B) {
testStore, err := newTestStore(b)
require.NoError(b, err)
defer testStore.Close()

b.ReportAllocs()
b.ResetTimer()
Expand All @@ -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)
Expand All @@ -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()
Expand Down
16 changes: 16 additions & 0 deletions mysql/mysql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -246,20 +257,23 @@ 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())
}

func Test_MYSQL_Conn(t *testing.T) {
testStore, err := newTestStore(t)
require.NoError(t, err)
defer testStore.Close()

require.True(t, testStore.Conn() != nil)
}

func Benchmark_MYSQL_Set(b *testing.B) {
testStore, err := newTestStore(b)
require.NoError(b, err)
defer testStore.Close()

b.ReportAllocs()
b.ResetTimer()
Expand All @@ -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)
Expand All @@ -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()
Expand Down
Loading

0 comments on commit 1bb4d92

Please sign in to comment.