瀏覽代碼

make sure timeout in context timeout test

Unknown 6 年之前
父節點
當前提交
4a0e4251ee
共有 2 個文件被更改,包括 5 次插入0 次删除
  1. 2 0
      engine_context_test.go
  2. 3 0
      session_context_test.go

+ 2 - 0
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")

+ 3 - 0
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")