Skip to content

Commit

Permalink
TestCopyRespLoopConnectionError: Always ignore errors on stmt.Close()
Browse files Browse the repository at this point in the history
Since recent versions of Go now report the error in Stmt.Close(), we
should not expect it to be nil.
  • Loading branch information
markottt committed Jan 14, 2016
1 parent cd0a25b commit 8ad2b29
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions copy_test.go
Expand Up @@ -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 {
Expand All @@ -404,20 +405,15 @@ 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)
}
} else if pge.Code.Name() != "admin_shutdown" {
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) {
Expand Down

0 comments on commit 8ad2b29

Please sign in to comment.