Index: go/src/infra/gae/libs/gae/dummy_test.go |
diff --git a/go/src/infra/gae/libs/wrapper/dummy_test.go b/go/src/infra/gae/libs/gae/dummy_test.go |
similarity index 50% |
rename from go/src/infra/gae/libs/wrapper/dummy_test.go |
rename to go/src/infra/gae/libs/gae/dummy_test.go |
index 61e8ab2c09228ee875d141a5982736c022460138..8b167bf29b7be807628372ca5142fbd3e296c6ee 100644 |
--- a/go/src/infra/gae/libs/wrapper/dummy_test.go |
+++ b/go/src/infra/gae/libs/gae/dummy_test.go |
@@ -2,7 +2,7 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-package wrapper |
+package gae |
import ( |
"math/rand" |
@@ -11,10 +11,9 @@ import ( |
"golang.org/x/net/context" |
- "appengine/memcache" |
+ "github.com/luci/luci-go/common/clock/testclock" |
. "github.com/smartystreets/goconvey/convey" |
- "infra/libs/clock/testclock" |
) |
func TestContextAccess(t *testing.T) { |
@@ -23,22 +22,21 @@ func TestContextAccess(t *testing.T) { |
c, _ := testclock.UseTime(context.Background(), now) |
Convey("blank", func() { |
- So(GetDS(c), ShouldBeNil) |
So(GetMC(c), ShouldBeNil) |
So(GetTQ(c), ShouldBeNil) |
So(GetGI(c), ShouldBeNil) |
}) |
- Convey("DS", func() { |
- c = SetDS(c, DummyDS()) |
- So(GetDS(c), ShouldNotBeNil) |
- So(func() { GetDS(c).Kind(nil) }, ShouldPanic) |
+ Convey("RDS", func() { |
+ c = SetRDS(c, DummyRDS()) |
+ So(GetRDS(c), ShouldNotBeNil) |
+ So(func() { GetRDS(c).NewKey("", "", 1, nil) }, ShouldPanic) |
}) |
Convey("MC", func() { |
c = SetMC(c, DummyMC()) |
So(GetMC(c), ShouldNotBeNil) |
- So(func() { GetMC(c).InflateCodec(memcache.Codec{}) }, ShouldPanic) |
+ So(func() { GetMC(c).Add(nil) }, ShouldPanic) |
}) |
Convey("TQ", func() { |
@@ -59,18 +57,29 @@ func TestContextAccess(t *testing.T) { |
}) |
Convey("MathRand", func() { |
- r := rand.New(rand.NewSource(now.UnixNano())) |
- i := r.Int() |
+ // Note that the non-randomness below is because time is fixed at the |
+ // top of the outer test function. Normally it would evolve with time. |
+ Convey("unset", func() { |
+ r := rand.New(rand.NewSource(now.UnixNano())) |
+ i := r.Int() |
+ So(GetMathRand(c).Int(), ShouldEqual, i) |
+ So(GetMathRand(c).Int(), ShouldEqual, i) |
+ }) |
- // when it's unset it picks the current time every time |
- So(GetMathRand(c).Int(), ShouldEqual, i) |
- So(GetMathRand(c).Int(), ShouldEqual, i) |
+ Convey("set persistance", func() { |
+ 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()) |
+ }) |
- // 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()) |
+ Convey("nil set", func() { |
+ c = SetMathRand(c, nil) |
+ r := rand.New(rand.NewSource(now.UnixNano())) |
+ i := r.Int() |
+ So(GetMathRand(c).Int(), ShouldEqual, i) |
+ So(GetMathRand(c).Int(), ShouldEqual, i) |
+ }) |
}) |
}) |
} |