From 674c9089dfee72bc549a7482dd6820c7478bba43 Mon Sep 17 00:00:00 2001 From: BetaCat Date: Tue, 23 Jul 2019 15:35:33 +0800 Subject: [PATCH] make sure timeout in context timeout test (#1363) --- engine_context_test.go | 2 ++ session_context_test.go | 3 +++ 2 files changed, 5 insertions(+) diff --git a/engine_context_test.go b/engine_context_test.go index cc564694..1a3276ce 100644 --- a/engine_context_test.go +++ b/engine_context_test.go @@ -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") diff --git a/session_context_test.go b/session_context_test.go index b6fd1f6e..2784468d 100644 --- a/session_context_test.go +++ b/session_context_test.go @@ -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")