Improve test coverage

This commit is contained in:
TwinProduction
2021-07-18 00:34:22 -04:00
committed by Chris
parent 1a597f92ba
commit aac72e3741
3 changed files with 31 additions and 10 deletions

View File

@@ -242,12 +242,23 @@ func TestStore_Persistence(t *testing.T) {
}
}
func TestStore_Save(t *testing.T) {
store, _ := NewStore("sqlite", t.TempDir()+"/TestStore_Save.db")
defer store.Close()
if store.Save() != nil {
t.Error("Save shouldn't do anything for this store")
}
}
// TestStore_InvalidTransaction tests what happens if an invalid transaction is passed as parameter
func TestStore_InvalidTransaction(t *testing.T) {
store, _ := NewStore("sqlite", t.TempDir()+"/TestStore_InvalidTransaction.db")
defer store.Close()
tx, _ := store.db.Begin()
tx.Commit()
if _, err := store.insertService(tx, &testService); err == nil {
t.Error("should've returned an error, because the transaction was already committed")
}
if err := store.insertEvent(tx, 1, core.NewEventFromResult(&testSuccessfulResult)); err == nil {
t.Error("should've returned an error, because the transaction was already committed")
}