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/testclock/testtimer_test.go

Issue 1154213012: Add context-aware "time" library wrapper. (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Refactored into sub-packages. 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 (c) 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 testclock
6
7 import (
8 "testing"
9 "time"
10
11 . "github.com/smartystreets/goconvey/convey"
12 )
13
14 func TestTestTimer(t *testing.T) {
15 Convey(`A timer instance`, t, func() {
16 t := NewTimer()
17
18 Convey(`Should have a non-nil C.`, func() {
19 So(t.GetC(), ShouldNotBeNil)
20 })
21
22 Convey(`When set to Active`, func() {
23 t.(*timer).active = true
24
25 Convey(`When reset, should return active.`, func() {
26 active := t.Reset(1 * time.Hour)
27 So(active, ShouldBeTrue)
28 })
29
30 Convey(`When stopped, should return active.`, func() {
31 So(t.Stop(), ShouldBeTrue)
32
33 Convey(`And when stopped again, should return in active.`, func() {
34 So(t.Stop(), ShouldBeFalse)
35 })
36 })
37 })
38
39 Convey(`Should successfully signal.`, func() {
40 t.Signal(time.Time{})
41
42 var signalled bool
43 select {
44 case <-t.GetC():
45 signalled = true
46 default:
47 break
48 }
49 So(signalled, ShouldBeTrue)
50 })
51 })
52 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698