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

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: fix errcheck in test... 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
« no previous file with comments | « impl/memory/datastore_data.go ('k') | service/datastore/testable.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: impl/memory/datastore_test.go
diff --git a/impl/memory/datastore_test.go b/impl/memory/datastore_test.go
index c604991159b633d75954698458516370256a3c7a..0c1e39a2706bd0145c1fd19bd1a83b6b9f8da93a 100644
--- a/impl/memory/datastore_test.go
+++ b/impl/memory/datastore_test.go
@@ -91,6 +91,21 @@ func TestDatastoreSingleReadWriter(t *testing.T) {
So(ds.Delete(ds.NewKey("Foo", "wat", 0, nil)), ShouldBeNil)
})
+ Convey("Deleting entities from a nonexistant namespace works", func() {
+ aid := infoS.Get(c).FullyQualifiedAppID()
+ keys := make([]*dsS.Key, 10)
+ for i := range keys {
+ keys[i] = ds.MakeKey(aid, "noexist", "Kind", i+1)
+ }
+ So(ds.DeleteMulti(keys), ShouldBeNil)
+ count := 0
+ So(ds.Raw().DeleteMulti(keys, func(err error) {
+ count++
+ So(err, ShouldBeNil)
+ }), ShouldBeNil)
+ So(count, ShouldEqual, len(keys))
+ })
+
Convey("with multiple puts", func() {
So(testGetMeta(c, k), ShouldEqual, 1)
@@ -457,6 +472,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)
+
+ So(ds.Delete(ds.MakeKey("Foo", 4)), ShouldBeNil)
+
+ 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)
+
+ So(ds.Delete(ds.MakeKey("Foo", 4)), ShouldBeNil)
+
+ count, err = ds.Count(q)
+ So(err, ShouldBeNil)
+ So(count, ShouldEqual, 6)
+ })
+ })
})
}
« no previous file with comments | « impl/memory/datastore_data.go ('k') | service/datastore/testable.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698