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

Unified Diff: service/datastore/key_test.go

Issue 1377863004: Add Key.HasAncestor() (Closed) Base URL: https://github.com/luci/gae.git@master
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
« no previous file with comments | « service/datastore/key.go ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: service/datastore/key_test.go
diff --git a/service/datastore/key_test.go b/service/datastore/key_test.go
index f334f66dc9106e71932cb60b5c7f117a781fd131..d1e9d2096778d736c270e8f9e6eb1406b5862a9d 100644
--- a/service/datastore/key_test.go
+++ b/service/datastore/key_test.go
@@ -155,6 +155,23 @@ func TestMiscKey(t *testing.T) {
So(k1.String(), ShouldEqual, "a:n:/knd,1/other,\"wat\"")
})
+ Convey("HasAncestor", t, func() {
+ k1 := MakeKey("a", "n", "kind", 1)
+ k2 := MakeKey("a", "n", "kind", 1, "other", "wat")
+ k3 := MakeKey("a", "n", "kind", 1, "other", "wat", "extra", "data")
+ k4 := MakeKey("something", "n", "kind", 1)
+ k5 := MakeKey("a", "n", "kind", 1, "other", "meep")
+
+ So(k1.HasAncestor(k1), ShouldBeTrue)
+ So(k1.HasAncestor(k2), ShouldBeFalse)
+ So(k2.HasAncestor(k5), ShouldBeFalse)
+ So(k5.HasAncestor(k2), ShouldBeFalse)
+ So(k2.HasAncestor(k1), ShouldBeTrue)
+ So(k3.HasAncestor(k2), ShouldBeTrue)
+ So(k3.HasAncestor(k1), ShouldBeTrue)
+ So(k3.HasAncestor(k4), ShouldBeFalse)
+ })
+
Convey("*GenericKey supports json encoding", t, func() {
type TestStruct struct {
Key *Key
« no previous file with comments | « service/datastore/key.go ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698