Index: go/src/infra/gae/libs/wrapper/dummy_test.go |
diff --git a/go/src/infra/gae/libs/wrapper/dummy_test.go b/go/src/infra/gae/libs/wrapper/dummy_test.go |
index 9d4f101fb4a3de271b4477e1c2c332ed868497a3..265c20939c1dca175858c3c050ae1999d1746352 100644 |
--- a/go/src/infra/gae/libs/wrapper/dummy_test.go |
+++ b/go/src/infra/gae/libs/wrapper/dummy_test.go |
@@ -14,20 +14,23 @@ import ( |
"appengine/memcache" |
. "github.com/smartystreets/goconvey/convey" |
+ "infra/libs/clock" |
+ "infra/libs/clock/testclock" |
) |
func TestContextAccess(t *testing.T) { |
Convey("Context Access", t, func() { |
c := context.Background() |
+ now := time.Date(2015, 1, 1, 0, 0, 0, 0, time.UTC) |
+ tc := testclock.New(now) |
+ c = clock.SetClock(c, tc) |
iannucci
2015/06/03 17:37:19
wdyt about
c = testclock.UseTime(c, time.Date(
dnj
2015/06/03 18:21:26
You need a reference to the test clock in order to
|
+ |
Convey("blank", func() { |
So(GetDS(c), ShouldBeNil) |
So(GetMC(c), ShouldBeNil) |
So(GetTQ(c), ShouldBeNil) |
So(GetGI(c), ShouldBeNil) |
- |
- now := time.Now() |
- So(GetTimeNow(c), ShouldHappenOnOrAfter, now) |
}) |
Convey("DS", func() { |
@@ -59,30 +62,19 @@ func TestContextAccess(t *testing.T) { |
So(func() { q.Distinct() }, ShouldPanic) |
}) |
- Convey("TimeNow", func() { |
- thing := time.Date(2000, time.August, 20, 0, 0, 0, 0, time.UTC) |
- c = SetTimeNow(c, &thing) |
- So(GetTimeNow(c), ShouldResemble, thing) |
- |
- Convey("MathRand", func() { |
- r := rand.New(rand.NewSource(thing.UnixNano())) |
- i := r.Int() |
- |
- // when it's unset it picks TimeNow every time |
- So(GetMathRand(c).Int(), ShouldEqual, i) |
- So(GetMathRand(c).Int(), ShouldEqual, i) |
- |
- // But we could set it to something concrete to have it persist. |
- c = SetMathRand(c, rand.New(rand.NewSource(thing.UnixNano()))) |
- r = rand.New(rand.NewSource(thing.UnixNano())) |
- So(GetMathRand(c).Int(), ShouldEqual, r.Int()) |
- So(GetMathRand(c).Int(), ShouldEqual, r.Int()) |
- }) |
- |
- c = SetTimeNow(c, nil) |
- now := time.Now() |
- So(GetTimeNow(c), ShouldHappenOnOrAfter, now) |
- }) |
+ Convey("MathRand", func() { |
+ r := rand.New(rand.NewSource(now.UnixNano())) |
+ i := r.Int() |
+ // when it's unset it picks the current time every time |
+ So(GetMathRand(c).Int(), ShouldEqual, i) |
+ So(GetMathRand(c).Int(), ShouldEqual, i) |
+ |
+ // But we could set it to something concrete to have it persist. |
+ c = SetMathRand(c, rand.New(rand.NewSource(now.UnixNano()))) |
+ r = rand.New(rand.NewSource(now.UnixNano())) |
+ So(GetMathRand(c).Int(), ShouldEqual, r.Int()) |
+ So(GetMathRand(c).Int(), ShouldEqual, r.Int()) |
+ }) |
}) |
} |