diff --git a/copy_test.go b/copy_test.go index 2c675eda..86745b38 100644 --- a/copy_test.go +++ b/copy_test.go @@ -382,6 +382,7 @@ func TestCopyRespLoopConnectionError(t *testing.T) { if err != nil { t.Fatal(err) } + defer stmt.Close() _, err = db.Exec("SELECT pg_terminate_backend($1)", pid) if err != nil { @@ -404,9 +405,7 @@ func TestCopyRespLoopConnectionError(t *testing.T) { pge, ok := err.(*Error) if !ok { if err == driver.ErrBadConn { - // Likely an EPIPE - _ = stmt.Close() - return + // likely an EPIPE } else { t.Fatalf("expected *pq.Error or driver.ErrBadConn, got %+#v", err) } @@ -414,10 +413,7 @@ func TestCopyRespLoopConnectionError(t *testing.T) { t.Fatalf("expected admin_shutdown, got %s", pge.Code.Name()) } - err = stmt.Close() - if err != nil { - t.Fatal(err) - } + _ = stmt.Close() } func BenchmarkCopyIn(b *testing.B) {