| Index: common/clock/testclock/testtimer_test.go
|
| diff --git a/common/clock/testclock/testtimer_test.go b/common/clock/testclock/testtimer_test.go
|
| index 90234e43ada67a3c9208c30444d22721c9b8e2a6..dccf1a8756a7cabe98ff1adf1c56cf13a09ad81c 100644
|
| --- a/common/clock/testclock/testtimer_test.go
|
| +++ b/common/clock/testclock/testtimer_test.go
|
| @@ -9,6 +9,8 @@ import (
|
| "time"
|
|
|
| "github.com/luci/luci-go/common/clock"
|
| + "golang.org/x/net/context"
|
| +
|
| . "github.com/smartystreets/goconvey/convey"
|
| )
|
|
|
| @@ -16,14 +18,15 @@ func TestTestTimer(t *testing.T) {
|
| t.Parallel()
|
|
|
| Convey(`A testing clock instance`, t, func() {
|
| - now := time.Date(2015, 01, 01, 00, 00, 00, 00, time.UTC)
|
| + ctx := context.Background()
|
| + now := TestTimeLocal
|
| c := New(now)
|
|
|
| Convey(`A timer instance`, func() {
|
| - t := c.NewTimer()
|
| + t := c.NewTimer(ctx)
|
|
|
| Convey(`Should have a non-nil C.`, func() {
|
| - So(t.GetC(), ShouldBeNil)
|
| + So(t.GetC(), ShouldNotBeNil)
|
| })
|
|
|
| Convey(`When activated`, func() {
|
| @@ -36,11 +39,11 @@ func TestTestTimer(t *testing.T) {
|
|
|
| Convey(`When stopped, should return active.`, func() {
|
| So(t.Stop(), ShouldBeTrue)
|
| - So(t.GetC(), ShouldBeNil)
|
| + So(t.GetC(), ShouldNotBeNil)
|
|
|
| Convey(`And when stopped again, should return inactive.`, func() {
|
| So(t.Stop(), ShouldBeFalse)
|
| - So(t.GetC(), ShouldBeNil)
|
| + So(t.GetC(), ShouldNotBeNil)
|
| })
|
| })
|
|
|
| @@ -63,12 +66,11 @@ func TestTestTimer(t *testing.T) {
|
| So(t.Reset(1*time.Second), ShouldBeFalse)
|
| c.Add(1 * time.Second)
|
|
|
| - So(t.GetC(), ShouldNotBeNil)
|
| - So(<-t.GetC(), ShouldResemble, now.Add(1*time.Second))
|
| + So(<-t.GetC(), ShouldResemble, clock.TimerResult{Time: now.Add(1 * time.Second)})
|
| })
|
| })
|
|
|
| - Convey(`Multiple goroutines using the timer...`, func() {
|
| + Convey(`Multiple goroutines using timers...`, func() {
|
| // Mark when timers are started, so we can ensure that our signalling
|
| // happens after the timers have been instantiated.
|
| timerStartedC := make(chan bool)
|
| @@ -76,10 +78,10 @@ func TestTestTimer(t *testing.T) {
|
| timerStartedC <- true
|
| })
|
|
|
| - resultC := make(chan time.Time)
|
| + resultC := make(chan clock.TimerResult)
|
| for i := time.Duration(0); i < 5; i++ {
|
| go func(d time.Duration) {
|
| - timer := c.NewTimer()
|
| + timer := c.NewTimer(ctx)
|
| timer.Reset(d)
|
| resultC <- <-timer.GetC()
|
| }(i * time.Second)
|
|
|