| Index: go/src/infra/libs/clock/testclock/testtimer_test.go
|
| diff --git a/go/src/infra/libs/clock/testclock/testtimer_test.go b/go/src/infra/libs/clock/testclock/testtimer_test.go
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..685eeb582529b2d5eb669edb2b2529d98308dca5
|
| --- /dev/null
|
| +++ b/go/src/infra/libs/clock/testclock/testtimer_test.go
|
| @@ -0,0 +1,52 @@
|
| +// Copyright (c) 2015 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +package testclock
|
| +
|
| +import (
|
| + "testing"
|
| + "time"
|
| +
|
| + . "github.com/smartystreets/goconvey/convey"
|
| +)
|
| +
|
| +func TestTestTimer(t *testing.T) {
|
| + Convey(`A timer instance`, t, func() {
|
| + t := NewTimer()
|
| +
|
| + Convey(`Should have a non-nil C.`, func() {
|
| + So(t.GetC(), ShouldNotBeNil)
|
| + })
|
| +
|
| + Convey(`When set to Active`, func() {
|
| + t.(*timer).active = true
|
| +
|
| + Convey(`When reset, should return active.`, func() {
|
| + active := t.Reset(1 * time.Hour)
|
| + So(active, ShouldBeTrue)
|
| + })
|
| +
|
| + Convey(`When stopped, should return active.`, func() {
|
| + So(t.Stop(), ShouldBeTrue)
|
| +
|
| + Convey(`And when stopped again, should return inactive.`, func() {
|
| + So(t.Stop(), ShouldBeFalse)
|
| + })
|
| + })
|
| + })
|
| +
|
| + Convey(`Should successfully signal.`, func() {
|
| + t.Signal(time.Time{})
|
| +
|
| + var signalled bool
|
| + select {
|
| + case <-t.GetC():
|
| + signalled = true
|
| + default:
|
| + break
|
| + }
|
| + So(signalled, ShouldBeTrue)
|
| + })
|
| + })
|
| +}
|
|
|