1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2025-12-29 05:25:21 -05:00

fully migrate to new assertion lib

This commit is contained in:
Darien Raymond
2017-10-24 16:15:35 +02:00
parent 4a0ca30d08
commit 74cf833758
70 changed files with 974 additions and 942 deletions

View File

@@ -7,26 +7,26 @@ import (
"time"
. "v2ray.com/core/common/signal"
"v2ray.com/core/testing/assert"
. "v2ray.com/ext/assert"
)
func TestActivityTimer(t *testing.T) {
assert := assert.On(t)
assert := With(t)
ctx, timer := CancelAfterInactivity(context.Background(), time.Second*5)
time.Sleep(time.Second * 6)
assert.Error(ctx.Err()).IsNotNil()
assert(ctx.Err(), IsNotNil)
runtime.KeepAlive(timer)
}
func TestActivityTimerUpdate(t *testing.T) {
assert := assert.On(t)
assert := With(t)
ctx, timer := CancelAfterInactivity(context.Background(), time.Second*10)
time.Sleep(time.Second * 3)
assert.Error(ctx.Err()).IsNil()
assert(ctx.Err(), IsNil)
timer.SetTimeout(time.Second * 1)
time.Sleep(time.Second * 2)
assert.Error(ctx.Err()).IsNotNil()
assert(ctx.Err(), IsNotNil)
runtime.KeepAlive(timer)
}