mirror of
https://github.com/TwiN/gatus.git
synced 2024-12-14 11:58:04 +00:00
Increase test coverage and remove useless code
This commit is contained in:
parent
56fedcedd1
commit
1a597f92ba
2 changed files with 3 additions and 12 deletions
|
@ -644,16 +644,10 @@ func (s *Store) getNumberOfEventsByServiceID(tx *sql.Tx, serviceID int64) (int64
|
|||
return 0, err
|
||||
}
|
||||
var numberOfEvents int64
|
||||
var found bool
|
||||
for rows.Next() {
|
||||
_ = rows.Scan(&numberOfEvents)
|
||||
found = true
|
||||
break
|
||||
}
|
||||
_ = rows.Close()
|
||||
if !found {
|
||||
return 0, errNoRowsReturned
|
||||
}
|
||||
return numberOfEvents, nil
|
||||
}
|
||||
|
||||
|
@ -663,16 +657,10 @@ func (s *Store) getNumberOfResultsByServiceID(tx *sql.Tx, serviceID int64) (int6
|
|||
return 0, err
|
||||
}
|
||||
var numberOfResults int64
|
||||
var found bool
|
||||
for rows.Next() {
|
||||
_ = rows.Scan(&numberOfResults)
|
||||
found = true
|
||||
break
|
||||
}
|
||||
_ = rows.Close()
|
||||
if !found {
|
||||
return 0, errNoRowsReturned
|
||||
}
|
||||
return numberOfResults, nil
|
||||
}
|
||||
|
||||
|
|
|
@ -248,6 +248,9 @@ func TestStore_InvalidTransaction(t *testing.T) {
|
|||
defer store.Close()
|
||||
tx, _ := store.db.Begin()
|
||||
tx.Commit()
|
||||
if err := store.insertEvent(tx, 1, core.NewEventFromResult(&testSuccessfulResult)); err == nil {
|
||||
t.Error("should've returned an error, because the transaction was already committed")
|
||||
}
|
||||
if err := store.insertResult(tx, 1, &testSuccessfulResult); err == nil {
|
||||
t.Error("should've returned an error, because the transaction was already committed")
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue