aboutsummaryrefslogtreecommitdiffstats
path: root/internal/storage/db_test.go
diff options
context:
space:
mode:
authorEugene Triguba <eugenetriguba@gmail.com>2024-03-11 20:42:20 -0400
committerEugene Triguba <eugenetriguba@gmail.com>2024-03-11 20:42:20 -0400
commit95423212626f490b8c6434b420a4cd567110f41a (patch)
treedcaf53d9ec06e1a3ca8f3ff37787d9feb4ccba4b /internal/storage/db_test.go
parentUpdate readme config reference (diff)
downloadcli-95423212626f490b8c6434b420a4cd567110f41a.zip
Tweak table cleanup logic for tests
Diffstat (limited to 'internal/storage/db_test.go')
-rw-r--r--internal/storage/db_test.go8
1 files changed, 4 insertions, 4 deletions
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!")