improve UT case for package gtimer

This commit is contained in:
John Guo
2022-02-17 22:45:06 +08:00
parent 17d7c92b9d
commit fdf09b5978

View File

@ -121,12 +121,12 @@ func TestDelayAddSingleton(t *testing.T) {
func TestDelayAddOnce(t *testing.T) {
gtest.C(t, func(t *gtest.T) {
array := garray.New(true)
gtimer.DelayAddOnce(ctx, 200*time.Millisecond, 200*time.Millisecond, func(ctx context.Context) {
gtimer.DelayAddOnce(ctx, 1000*time.Millisecond, 2000*time.Millisecond, func(ctx context.Context) {
array.Append(1)
})
time.Sleep(300 * time.Millisecond)
time.Sleep(2000 * time.Millisecond)
t.Assert(array.Len(), 0)
time.Sleep(1000 * time.Millisecond)
time.Sleep(2000 * time.Millisecond)
t.Assert(array.Len(), 1)
})
}