Skip to content

Commit 5630d39

Browse files
committed
database/sql: fix nits in test
Change-Id: I451b33d8da8d97917f2b257e6a25392c6e6582db Reviewed-on: https://go-review.googlesource.com/36671 Run-TryBot: Mikio Hara <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Brad Fitzpatrick <[email protected]>
1 parent 3c22e5c commit 5630d39

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/database/sql/sql_test.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ func TestQueryContext(t *testing.T) {
316316
select {
317317
case <-ctx.Done():
318318
if err := ctx.Err(); err != context.Canceled {
319-
t.Fatalf("context err = %v; want context.Canceled")
319+
t.Fatalf("context err = %v; want context.Canceled", err)
320320
}
321321
default:
322322
t.Fatalf("context err = nil; want context.Canceled")
@@ -365,7 +365,8 @@ func TestQueryContextWait(t *testing.T) {
365365
defer closeDB(t, db)
366366
prepares0 := numPrepares(t, db)
367367

368-
ctx, _ := context.WithTimeout(context.Background(), time.Millisecond*15)
368+
ctx, cancel := context.WithTimeout(context.Background(), time.Millisecond*15)
369+
defer cancel()
369370

370371
// This will trigger the *fakeConn.Prepare method which will take time
371372
// performing the query. The ctxDriverPrepare func will check the context
@@ -386,7 +387,8 @@ func TestTxContextWait(t *testing.T) {
386387
db := newTestDB(t, "people")
387388
defer closeDB(t, db)
388389

389-
ctx, _ := context.WithTimeout(context.Background(), time.Millisecond*15)
390+
ctx, cancel := context.WithTimeout(context.Background(), time.Millisecond*15)
391+
defer cancel()
390392

391393
tx, err := db.BeginTx(ctx, nil)
392394
if err != nil {

0 commit comments

Comments
 (0)