mirror of
https://gitee.com/johng/gf
synced 2026-07-07 22:27:06 +08:00
improve UT case for package gtimer
This commit is contained in:
@ -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)
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user