Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions conn_with_mockserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ func TestSetIsolationLevel(t *testing.T) {
if g, w := level, sql.LevelSnapshot; g != w {
t.Fatalf("isolation level mismatch\n Got: %v\nWant: %v", g, w)
}
conn.Close()
_ = conn.Close()
}
}

Expand Down Expand Up @@ -335,7 +335,7 @@ func TestDDLUsingQueryContextInReadOnlyTx(t *testing.T) {
if err != nil {
t.Fatal(err)
}
defer tx.Rollback()
defer func() { _ = tx.Rollback() }()

// DDL statements should not use the query context in a read-only transaction.
_, err = tx.QueryContext(ctx, "CREATE TABLE Foo (Bar STRING(100))")
Expand All @@ -358,7 +358,7 @@ func TestDDLUsingQueryContextInReadWriteTransaction(t *testing.T) {
if err != nil {
t.Fatal(err)
}
defer tx.Rollback()
defer func() { _ = tx.Rollback() }()

// DDL statements should not use the query context in a read-write transaction.
_, err = tx.QueryContext(ctx, "CREATE TABLE Foo (Bar STRING(100))")
Expand Down
6 changes: 3 additions & 3 deletions connection_leak_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func simpleQuery(ctx context.Context, t *testing.T, db *sql.DB) {
if err != nil {
t.Fatal(err)
}
defer rows.Close()
defer silentClose(rows)

for want := int64(1); rows.Next(); want++ {
_, err := rows.Columns()
Expand Down Expand Up @@ -202,7 +202,7 @@ func readOnlyTxWithStaleness(ctx context.Context, t *testing.T, db *sql.DB) {
if err != nil {
t.Fatal(err)
}
defer conn.Close()
defer silentClose(conn)
if _, err := conn.ExecContext(ctx, "SET READ_ONLY_STALENESS = 'EXACT_STALENESS 10s'"); err != nil {
t.Fatalf("Set read-only staleness: %v", err)
}
Expand Down Expand Up @@ -233,7 +233,7 @@ func simpleReadWriteTx(ctx context.Context, t *testing.T, db *sql.DB) {
if err != nil {
t.Fatal(err)
}
defer conn.Close()
defer silentClose(conn)
if _, err := conn.ExecContext(ctx, "set max_commit_delay='10ms'"); err != nil {
t.Fatal(err)
}
Expand Down
8 changes: 7 additions & 1 deletion driver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"database/sql/driver"
"encoding/json"
"fmt"
"io"
"net"
"reflect"
"testing"
Expand All @@ -34,7 +35,12 @@ import (
"google.golang.org/grpc/codes"
)

func silentClose(c io.Closer) {
_ = c.Close()
}

func TestExtractDnsParts(t *testing.T) {
//goland:noinspection GoDeprecation
tests := []struct {
input string
wantConnectorConfig ConnectorConfig
Expand Down Expand Up @@ -470,7 +476,7 @@ func ExampleCreateConnector() {
db := sql.OpenDB(c)
// Use the database ...

defer db.Close()
defer silentClose(db)
}

func TestConnection_Reset(t *testing.T) {
Expand Down
Loading
Loading