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

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: Removed goroutine safety from testtimer. 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
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) {
iannucci 2015/06/03 17:37:20 in general we should be in the habit of starting a
dnj 2015/06/03 18:21:27 Done.
15 Convey(`A systemTimer instance`, t, func() {
16 t := new(systemTimer)
17
18 Convey(`Should start with a nil channel.`, func() {
19 So(t.GetC(), ShouldBeNil)
20 })
21
22 Convey(`When stopped, should return inactive.`, func() {
23 So(t.Stop(), ShouldBeFalse)
24 })
25
26 Convey(`When reset`, func() {
27 active := t.Reset(1 * time.Hour)
28 So(active, ShouldBeFalse)
29
30 Convey(`When reset to a short duration`, func() {
31 active := t.Reset(1 * time.Microsecond)
32
33 Convey(`Should return active.`, func() {
34 So(active, ShouldBeTrue)
35 })
36
37 Convey(`Should trigger shortly.`, func() {
38 tm := <-t.GetC()
39 So(tm, ShouldNotResemble, time.Time{})
40 })
41 })
42
43 Convey(`When stopped, should return active and have a no n-nil C.`, func() {
44 active := t.Stop()
45 So(active, ShouldBeTrue)
46 So(t.GetC(), ShouldNotBeNil)
47 })
48
49 Convey(`When stopped, should return active.`, func() {
50 active := t.Stop()
51 So(active, ShouldBeTrue)
52 })
53
54 Convey(`Should have a non-nil channel.`, func() {
55 So(t.GetC(), ShouldNotBeNil)
56 })
57
58 Reset(func() {
59 t.Stop()
60 })
61 })
62 })
63 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698