| Index: common/clock/systemtimer_test.go
|
| diff --git a/common/clock/systemtimer_test.go b/common/clock/systemtimer_test.go
|
| index 8b9cbc54174ea2dfe1f4d9fb861fe771ad73ecb0..39d0a731b054a1d967864118fa303dcbd13e63a6 100644
|
| --- a/common/clock/systemtimer_test.go
|
| +++ b/common/clock/systemtimer_test.go
|
| @@ -8,6 +8,8 @@ import (
|
| "testing"
|
| "time"
|
|
|
| + "golang.org/x/net/context"
|
| +
|
| . "github.com/smartystreets/goconvey/convey"
|
| )
|
|
|
| @@ -15,16 +17,24 @@ func TestSystemTimer(t *testing.T) {
|
| t.Parallel()
|
|
|
| Convey(`A systemTimer instance`, t, func() {
|
| - t := new(systemTimer)
|
| + ctx, cancelFunc := context.WithCancel(context.Background())
|
| + t := GetSystemClock().NewTimer(ctx)
|
| + defer t.Stop()
|
|
|
| - Convey(`Should start with a nil channel.`, func() {
|
| - So(t.GetC(), ShouldBeNil)
|
| + Convey(`Should start with a non-nil channel.`, func() {
|
| + So(t.GetC(), ShouldNotBeNil)
|
| })
|
|
|
| Convey(`When stopped, should return inactive.`, func() {
|
| So(t.Stop(), ShouldBeFalse)
|
| })
|
|
|
| + Convey(`Will return prematurely if canceled.`, func() {
|
| + t.Reset(time.Hour)
|
| + cancelFunc()
|
| + So((<-t.GetC()).Err, ShouldEqual, context.Canceled)
|
| + })
|
| +
|
| Convey(`When reset`, func() {
|
| active := t.Reset(1 * time.Hour)
|
| So(active, ShouldBeFalse)
|
| @@ -58,10 +68,6 @@ func TestSystemTimer(t *testing.T) {
|
| Convey(`Should have a non-nil channel.`, func() {
|
| So(t.GetC(), ShouldNotBeNil)
|
| })
|
| -
|
| - Reset(func() {
|
| - t.Stop()
|
| - })
|
| })
|
| })
|
| }
|
|
|