浏览代码

pkg/wait: fix TestWaitTestStress

The test may fail if two consequent time.Now() returns the same value.
Sleep 1ns to avoid this situation.
Yicheng Qin 10 年之前
父节点
当前提交
256a7cfe8c
共有 1 个文件被更改,包括 2 次插入0 次删除
  1. 2 0
      pkg/wait/wait_time_test.go

+ 2 - 0
pkg/wait/wait_time_test.go

@@ -53,6 +53,8 @@ func TestWaitTestStress(t *testing.T) {
 	wt := NewTimeList()
 	for i := 0; i < 10000; i++ {
 		chs = append(chs, wt.Wait(time.Now()))
+		// sleep one nanosecond before waiting on the next event
+		time.Sleep(time.Nanosecond)
 	}
 	wt.Trigger(time.Now())