make sure timeout in context timeout test (#1363)
This commit is contained in:
parent
62d884e8f1
commit
674c9089df
|
@ -20,6 +20,8 @@ func TestPingContext(t *testing.T) {
|
||||||
ctx, canceled := context.WithTimeout(context.Background(), time.Nanosecond)
|
ctx, canceled := context.WithTimeout(context.Background(), time.Nanosecond)
|
||||||
defer canceled()
|
defer canceled()
|
||||||
|
|
||||||
|
time.Sleep(time.Nanosecond)
|
||||||
|
|
||||||
err := testEngine.(*Engine).PingContext(ctx)
|
err := testEngine.(*Engine).PingContext(ctx)
|
||||||
assert.Error(t, err)
|
assert.Error(t, err)
|
||||||
assert.Contains(t, err.Error(), "context deadline exceeded")
|
assert.Contains(t, err.Error(), "context deadline exceeded")
|
||||||
|
|
|
@ -26,6 +26,9 @@ func TestQueryContext(t *testing.T) {
|
||||||
|
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), time.Nanosecond)
|
ctx, cancel := context.WithTimeout(context.Background(), time.Nanosecond)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
|
time.Sleep(time.Nanosecond)
|
||||||
|
|
||||||
has, err := testEngine.Context(ctx).Exist(&ContextQueryStruct{Name: "1"})
|
has, err := testEngine.Context(ctx).Exist(&ContextQueryStruct{Name: "1"})
|
||||||
assert.Error(t, err)
|
assert.Error(t, err)
|
||||||
assert.Contains(t, err.Error(), "context deadline exceeded")
|
assert.Contains(t, err.Error(), "context deadline exceeded")
|
||||||
|
|
Loading…
Reference in New Issue