1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2025-01-02 23:47:07 -05:00

test case for 0 timeout

This commit is contained in:
Darien Raymond 2018-05-28 14:02:09 +02:00
parent 6dbe2644a9
commit d6513ee4ec
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169
2 changed files with 10 additions and 0 deletions

View File

@ -42,6 +42,7 @@ func (t *ActivityTimer) finish() {
if t.onTimeout != nil {
t.onTimeout()
t.onTimeout = nil
}
if t.checkTask != nil {
t.checkTask.Close() // nolint: errcheck

View File

@ -44,3 +44,12 @@ func TestActivityTimerNonBlocking(t *testing.T) {
timer.SetTimeout(1)
timer.SetTimeout(2)
}
func TestActivityTimerZeroTimeout(t *testing.T) {
assert := With(t)
ctx, cancel := context.WithCancel(context.Background())
timer := CancelAfterInactivity(ctx, cancel, 0)
assert(ctx, HasDone)
runtime.KeepAlive(timer)
}