Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(254)

Unified Diff: impl/memory/datastore_test.go

Issue 1366793002: Add Consistent(bool) to Testing interface (Closed) Base URL: https://github.com/luci/gae.git@move_serialization_helpers
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: impl/memory/datastore_test.go
diff --git a/impl/memory/datastore_test.go b/impl/memory/datastore_test.go
index c604991159b633d75954698458516370256a3c7a..210e676b95d1ad065775f59bda2ac534c2b0242f 100644
--- a/impl/memory/datastore_test.go
+++ b/impl/memory/datastore_test.go
@@ -457,6 +457,47 @@ func TestDatastoreSingleReadWriter(t *testing.T) {
})
})
})
+
+ Convey("Testable.Consistent", func() {
+ Convey("false", func() {
+ ds.Testable().Consistent(false) // the default
+ for i := 0; i < 10; i++ {
+ So(ds.Put(&Foo{ID: int64(i + 1), Val: i + 1}), ShouldBeNil)
+ }
+ q := dsS.NewQuery("Foo").Gt("Val", 3)
+ count, err := ds.Count(q)
+ So(err, ShouldBeNil)
+ So(count, ShouldEqual, 0)
+
+ ds.Delete(ds.MakeKey("Foo", 4))
+
+ count, err = ds.Count(q)
+ So(err, ShouldBeNil)
+ So(count, ShouldEqual, 0)
+
+ ds.Testable().Consistent(true)
+ count, err = ds.Count(q)
+ So(err, ShouldBeNil)
+ So(count, ShouldEqual, 6)
+ })
+
+ Convey("true", func() {
+ ds.Testable().Consistent(true)
+ for i := 0; i < 10; i++ {
+ So(ds.Put(&Foo{ID: int64(i + 1), Val: i + 1}), ShouldBeNil)
+ }
+ q := dsS.NewQuery("Foo").Gt("Val", 3)
+ count, err := ds.Count(q)
+ So(err, ShouldBeNil)
+ So(count, ShouldEqual, 7)
+
+ ds.Delete(ds.MakeKey("Foo", 4))
+
+ count, err = ds.Count(q)
+ So(err, ShouldBeNil)
+ So(count, ShouldEqual, 6)
+ })
+ })
})
}

Powered by Google App Engine
This is Rietveld 408576698