mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
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 <mikioh.mikioh@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
parent
5630d39f0c
commit
3a6842a0ec
1 changed files with 7 additions and 7 deletions
|
|
@ -365,7 +365,7 @@ func TestQueryContextWait(t *testing.T) {
|
||||||
defer closeDB(t, db)
|
defer closeDB(t, db)
|
||||||
prepares0 := numPrepares(t, db)
|
prepares0 := numPrepares(t, db)
|
||||||
|
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), time.Millisecond*15)
|
ctx, cancel := context.WithTimeout(context.Background(), 15*time.Millisecond)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
// This will trigger the *fakeConn.Prepare method which will take time
|
// This will trigger the *fakeConn.Prepare method which will take time
|
||||||
|
|
@ -387,7 +387,7 @@ func TestTxContextWait(t *testing.T) {
|
||||||
db := newTestDB(t, "people")
|
db := newTestDB(t, "people")
|
||||||
defer closeDB(t, db)
|
defer closeDB(t, db)
|
||||||
|
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), time.Millisecond*15)
|
ctx, cancel := context.WithTimeout(context.Background(), 15*time.Millisecond)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
tx, err := db.BeginTx(ctx, nil)
|
tx, err := db.BeginTx(ctx, nil)
|
||||||
|
|
@ -566,13 +566,13 @@ func TestPoolExhaustOnCancel(t *testing.T) {
|
||||||
saturate.Wait()
|
saturate.Wait()
|
||||||
|
|
||||||
// Now cancel the request while it is waiting.
|
// Now cancel the request while it is waiting.
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), time.Second*2)
|
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
for i := 0; i < max; i++ {
|
for i := 0; i < max; i++ {
|
||||||
ctxReq, cancelReq := context.WithCancel(ctx)
|
ctxReq, cancelReq := context.WithCancel(ctx)
|
||||||
go func() {
|
go func() {
|
||||||
time.Sleep(time.Millisecond * 100)
|
time.Sleep(100 * time.Millisecond)
|
||||||
cancelReq()
|
cancelReq()
|
||||||
}()
|
}()
|
||||||
err := db.PingContext(ctxReq)
|
err := db.PingContext(ctxReq)
|
||||||
|
|
@ -1807,8 +1807,8 @@ func TestConnMaxLifetime(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Expire first conn
|
// Expire first conn
|
||||||
offset = time.Second * 11
|
offset = 11 * time.Second
|
||||||
db.SetConnMaxLifetime(time.Second * 10)
|
db.SetConnMaxLifetime(10 * time.Second)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
@ -2765,7 +2765,7 @@ func TestIssue18719(t *testing.T) {
|
||||||
|
|
||||||
// Wait for the context to cancel and tx to rollback.
|
// Wait for the context to cancel and tx to rollback.
|
||||||
for tx.isDone() == false {
|
for tx.isDone() == false {
|
||||||
time.Sleep(time.Millisecond * 3)
|
time.Sleep(3 * time.Millisecond)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
defer func() { hookTxGrabConn = nil }()
|
defer func() { hookTxGrabConn = nil }()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue