From b81d241c472c32059e9d34e1dbe5dfc0fbf236de Mon Sep 17 00:00:00 2001 From: Asdine El Hrychy Date: Fri, 30 Oct 2020 16:15:46 +0400 Subject: [PATCH] Check errors on deferred functions Co-authored-by: Ivan Trubach --- database/database_test.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/database/database_test.go b/database/database_test.go index 5ef107aea..882546e3b 100644 --- a/database/database_test.go +++ b/database/database_test.go @@ -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{}) @@ -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 @@ -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{}{} }()