From 95423212626f490b8c6434b420a4cd567110f41a Mon Sep 17 00:00:00 2001 From: Eugene Triguba Date: Mon, 11 Mar 2024 20:42:20 -0400 Subject: Tweak table cleanup logic for tests --- internal/storage/db_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'internal/storage') diff --git a/internal/storage/db_test.go b/internal/storage/db_test.go index f3386f5..02b134d 100644 --- a/internal/storage/db_test.go +++ b/internal/storage/db_test.go @@ -51,11 +51,11 @@ func TestClose_IsClosed(t *testing.T) { func TestTableExists_DoesExist(t *testing.T) { db, err := storage.NewDB(bolttest.NewTestConnectionConfig()) assert.Nil(t, err) + bolttest.DropTable(t, db, "tmp") t.Cleanup(func() { bolttest.DropTable(t, db, "tmp") assert.Nil(t, db.Close()) }) - bolttest.DropTable(t, db, "tmp") _, err = db.Exec("CREATE TABLE tmp(id int primary key);") assert.Nil(t, err) @@ -83,11 +83,11 @@ func TestQueryPlaceholders(t *testing.T) { cfg := bolttest.NewTestConnectionConfig() db, err := storage.NewDB(cfg) assert.Nil(t, err) + bolttest.DropTable(t, db, "tmp") t.Cleanup(func() { bolttest.DropTable(t, db, "tmp") assert.Nil(t, db.Close()) }) - bolttest.DropTable(t, db, "tmp") _, err = db.Exec(`CREATE TABLE tmp(id int primary key);`) assert.Nil(t, err) _, err = db.Exec(`INSERT INTO tmp(id) VALUES(1);`) @@ -114,11 +114,11 @@ func TestTx_Commit(t *testing.T) { cfg := bolttest.NewTestConnectionConfig() db, err := storage.NewDB(cfg) assert.Nil(t, err) + bolttest.DropTable(t, db, "tmp") t.Cleanup(func() { bolttest.DropTable(t, db, "tmp") assert.Nil(t, db.Close()) }) - bolttest.DropTable(t, db, "tmp") err = db.Tx(func(db storage.DB) error { _, err = db.Exec(`CREATE TABLE tmp(id int primary key);`) @@ -136,11 +136,11 @@ func TestTx_Rollback(t *testing.T) { cfg := bolttest.NewTestConnectionConfig() db, err := storage.NewDB(cfg) assert.Nil(t, err) + bolttest.DropTable(t, db, "tmp") t.Cleanup(func() { bolttest.DropTable(t, db, "tmp") assert.Nil(t, db.Close()) }) - bolttest.DropTable(t, db, "tmp") _, err = db.Exec(`CREATE TABLE tmp(id INT PRIMARY KEY);`) assert.Nil(t, err) expectedErr := errors.New("error!") -- cgit v1.2.3