Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(70)

Side by Side Diff: go/src/infra/libs/clock/systemtimer_test.go

Issue 1154213012: Add context-aware "time" library wrapper. (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Added coverage files. Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « go/src/infra/libs/clock/systemtimer.go ('k') | go/src/infra/libs/clock/testclock/context.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 package clock
6
7 import (
8 "testing"
9 "time"
10
11 . "github.com/smartystreets/goconvey/convey"
12 )
13
14 func TestSystemTimer(t *testing.T) {
15 t.Parallel()
16
17 Convey(`A systemTimer instance`, t, func() {
18 t := new(systemTimer)
19
20 Convey(`Should start with a nil channel.`, func() {
21 So(t.GetC(), ShouldBeNil)
22 })
23
24 Convey(`When stopped, should return inactive.`, func() {
25 So(t.Stop(), ShouldBeFalse)
26 })
27
28 Convey(`When reset`, func() {
29 active := t.Reset(1 * time.Hour)
30 So(active, ShouldBeFalse)
31
32 Convey(`When reset to a short duration`, func() {
33 active := t.Reset(1 * time.Microsecond)
34
35 Convey(`Should return active.`, func() {
36 So(active, ShouldBeTrue)
37 })
38
39 Convey(`Should trigger shortly.`, func() {
40 tm := <-t.GetC()
41 So(tm, ShouldNotResemble, time.Time{})
42 })
43 })
44
45 Convey(`When stopped, should return active and have a no n-nil C.`, func() {
46 active := t.Stop()
47 So(active, ShouldBeTrue)
48 So(t.GetC(), ShouldNotBeNil)
49 })
50
51 Convey(`When stopped, should return active.`, func() {
52 active := t.Stop()
53 So(active, ShouldBeTrue)
54 })
55
56 Convey(`Should have a non-nil channel.`, func() {
57 So(t.GetC(), ShouldNotBeNil)
58 })
59
60 Reset(func() {
61 t.Stop()
62 })
63 })
64 })
65 }
OLDNEW
« no previous file with comments | « go/src/infra/libs/clock/systemtimer.go ('k') | go/src/infra/libs/clock/testclock/context.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698