Skip to content

Commit

Permalink
Check errors on deferred functions
Browse files Browse the repository at this point in the history
Co-authored-by: Ivan Trubach <[email protected]>
  • Loading branch information
asdine and tie committed Oct 30, 2020
1 parent 99fe1fc commit b81d241
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions database/database_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ import (
func TestConcurrentTransactionManagement(t *testing.T) {
db, err := genji.Open(":memory:")
require.NoError(t, err)
defer db.Close()
defer func() {
require.NoError(t, db.Close())
}()

ch := make(chan struct{})
done := make(chan struct{})
Expand All @@ -28,7 +30,7 @@ func TestConcurrentTransactionManagement(t *testing.T) {
time.Sleep(time.Millisecond)

// 3. Commit or rollback T1.
tx.Rollback()
require.NoError(t, tx.Rollback())

// Wait for T2 to finish and return.
<-ch
Expand All @@ -42,7 +44,7 @@ func TestConcurrentTransactionManagement(t *testing.T) {
// Waits for T1 to finish.
tx, err := db.Begin(true)
require.NoError(t, err)
defer tx.Rollback()
require.NoError(t, tx.Rollback())

ch <- struct{}{}
}()
Expand Down

0 comments on commit b81d241

Please sign in to comment.