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

Unified Diff: service/datastore/datastore_test.go

Issue 1398103003: Add Exists and ExistsMulti convenience methods (Closed) Base URL: https://github.com/luci/gae.git@add_version_id
Patch Set: comments Created 5 years, 2 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 | « service/datastore/datastore.go ('k') | service/datastore/interface.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: service/datastore/datastore_test.go
diff --git a/service/datastore/datastore_test.go b/service/datastore/datastore_test.go
index 2c2967537051863ab635c181c8884c793e7dac40..d86123f523ef16a5d349cf9ebccd4c9580f9f1a4 100644
--- a/service/datastore/datastore_test.go
+++ b/service/datastore/datastore_test.go
@@ -90,6 +90,8 @@ func (f *fakeDatastore) GetMulti(keys []*Key, _meta MultiMetaGetter, cb GetMulti
for i, k := range keys {
if k.Kind() == "Fail" {
cb(nil, errors.New("GetMulti fail"))
+ } else if k.Kind() == "DNE" {
+ cb(nil, ErrNoSuchEntity)
} else {
cb(PropertyMap{"Value": {MkProperty(i + 1)}}, nil)
}
@@ -298,6 +300,19 @@ func TestKeyForObj(t *testing.T) {
So(ds.KeyForObj(pls).String(), ShouldEqual, `s~aid:ns:/Hello,"world"/CommonStruct,1`)
})
+ Convey("can see if things exist", func() {
+ e, err := ds.Exists(k)
+ So(err, ShouldBeNil)
+ So(e, ShouldBeTrue)
+
+ e, err = ds.Exists(ds.MakeKey("DNE", "nope"))
+ So(err, ShouldBeNil)
+ So(e, ShouldBeFalse)
+
+ _, err = ds.Exists(ds.MakeKey("Fail", "boom"))
+ So(err, ShouldErrLike, "GetMulti fail")
+ })
+
})
Convey("bad", func() {
« no previous file with comments | « service/datastore/datastore.go ('k') | service/datastore/interface.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698