Skip to content

Commit 3a6842a

Browse files
committed
database/sql: replace the expr of timeunit * N with N * timeunit in test
Change-Id: I97981b30a9629916f896cb989cc2a42a8bdbef47 Reviewed-on: https://go-review.googlesource.com/36672 Run-TryBot: Mikio Hara <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Brad Fitzpatrick <[email protected]>
1 parent 5630d39 commit 3a6842a

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/database/sql/sql_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ func TestQueryContextWait(t *testing.T) {
365365
defer closeDB(t, db)
366366
prepares0 := numPrepares(t, db)
367367

368-
ctx, cancel := context.WithTimeout(context.Background(), time.Millisecond*15)
368+
ctx, cancel := context.WithTimeout(context.Background(), 15*time.Millisecond)
369369
defer cancel()
370370

371371
// This will trigger the *fakeConn.Prepare method which will take time
@@ -387,7 +387,7 @@ func TestTxContextWait(t *testing.T) {
387387
db := newTestDB(t, "people")
388388
defer closeDB(t, db)
389389

390-
ctx, cancel := context.WithTimeout(context.Background(), time.Millisecond*15)
390+
ctx, cancel := context.WithTimeout(context.Background(), 15*time.Millisecond)
391391
defer cancel()
392392

393393
tx, err := db.BeginTx(ctx, nil)
@@ -566,13 +566,13 @@ func TestPoolExhaustOnCancel(t *testing.T) {
566566
saturate.Wait()
567567

568568
// Now cancel the request while it is waiting.
569-
ctx, cancel := context.WithTimeout(context.Background(), time.Second*2)
569+
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
570570
defer cancel()
571571

572572
for i := 0; i < max; i++ {
573573
ctxReq, cancelReq := context.WithCancel(ctx)
574574
go func() {
575-
time.Sleep(time.Millisecond * 100)
575+
time.Sleep(100 * time.Millisecond)
576576
cancelReq()
577577
}()
578578
err := db.PingContext(ctxReq)
@@ -1807,8 +1807,8 @@ func TestConnMaxLifetime(t *testing.T) {
18071807
}
18081808

18091809
// Expire first conn
1810-
offset = time.Second * 11
1811-
db.SetConnMaxLifetime(time.Second * 10)
1810+
offset = 11 * time.Second
1811+
db.SetConnMaxLifetime(10 * time.Second)
18121812
if err != nil {
18131813
t.Fatal(err)
18141814
}
@@ -2765,7 +2765,7 @@ func TestIssue18719(t *testing.T) {
27652765

27662766
// Wait for the context to cancel and tx to rollback.
27672767
for tx.isDone() == false {
2768-
time.Sleep(time.Millisecond * 3)
2768+
time.Sleep(3 * time.Millisecond)
27692769
}
27702770
}
27712771
defer func() { hookTxGrabConn = nil }()

0 commit comments

Comments
 (0)