make sure timeout in context timeout test (#1363)

This commit is contained in:
BetaCat 2019-07-23 15:35:33 +08:00 committed by Lunny Xiao
parent 62d884e8f1
commit 674c9089df
2 changed files with 5 additions and 0 deletions

View File

@ -20,6 +20,8 @@ func TestPingContext(t *testing.T) {
ctx, canceled := context.WithTimeout(context.Background(), time.Nanosecond)
defer canceled()
time.Sleep(time.Nanosecond)
err := testEngine.(*Engine).PingContext(ctx)
assert.Error(t, err)
assert.Contains(t, err.Error(), "context deadline exceeded")

View File

@ -26,6 +26,9 @@ func TestQueryContext(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), time.Nanosecond)
defer cancel()
time.Sleep(time.Nanosecond)
has, err := testEngine.Context(ctx).Exist(&ContextQueryStruct{Name: "1"})
assert.Error(t, err)
assert.Contains(t, err.Error(), "context deadline exceeded")