2
0

Call context.WithTimeout cancel function

This commit is contained in:
Valery Krivchikov
2018-09-15 13:23:09 +03:00
parent e44f0f24c4
commit c844a2402b
5 changed files with 24 additions and 12 deletions
+4 -2
View File
@@ -261,7 +261,8 @@ func TestConnBeginExContextCancel(t *testing.T) {
conn := mustConnect(t, mockConfig)
ctx, _ := context.WithTimeout(context.Background(), 50*time.Millisecond)
ctx, cancel := context.WithTimeout(context.Background(), 50*time.Millisecond)
defer cancel()
_, err = conn.BeginEx(ctx, nil)
if err != context.DeadlineExceeded {
@@ -315,7 +316,8 @@ func TestTxCommitExCancel(t *testing.T) {
t.Fatal(err)
}
ctx, _ := context.WithTimeout(context.Background(), 50*time.Millisecond)
ctx, cancel := context.WithTimeout(context.Background(), 50*time.Millisecond)
defer cancel()
err = tx.CommitEx(ctx)
if err != context.DeadlineExceeded {
t.Errorf("err => %v, want %v", err, context.DeadlineExceeded)