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

Unified Diff: service/datastore/datastore_test.go

Issue 1358063003: Add Kind/StringID/IntID back to Key. (Closed) Base URL: https://github.com/luci/gae.git@add_allocate_ids
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: service/datastore/datastore_test.go
diff --git a/service/datastore/datastore_test.go b/service/datastore/datastore_test.go
index c0343ff1f2929e7b615ed404156147dddde1415d..2c2967537051863ab635c181c8884c793e7dac40 100644
--- a/service/datastore/datastore_test.go
+++ b/service/datastore/datastore_test.go
@@ -58,7 +58,7 @@ func (f *fakeDatastore) Run(fq *FinalizedQuery, cb RawRunCB) error {
}
func (f *fakeDatastore) PutMulti(keys []*Key, vals []PropertyMap, cb PutMultiCB) error {
- if keys[0].Last().Kind == "FailAll" {
+ if keys[0].Kind() == "FailAll" {
return errors.New("PutMulti fail all")
}
assertExtra := false
@@ -67,7 +67,7 @@ func (f *fakeDatastore) PutMulti(keys []*Key, vals []PropertyMap, cb PutMultiCB)
}
for i, k := range keys {
err := error(nil)
- if k.Last().Kind == "Fail" {
+ if k.Kind() == "Fail" {
err = errors.New("PutMulti fail")
} else {
So(vals[i]["Value"], ShouldResemble, []Property{MkProperty(i)})
@@ -75,7 +75,7 @@ func (f *fakeDatastore) PutMulti(keys []*Key, vals []PropertyMap, cb PutMultiCB)
So(vals[i]["Extra"], ShouldResemble, []Property{MkProperty("whoa")})
}
if k.Incomplete() {
- k = NewKey(k.AppID(), k.Namespace(), k.Last().Kind, "", int64(i+1), k.Parent())
+ k = NewKey(k.AppID(), k.Namespace(), k.Kind(), "", int64(i+1), k.Parent())
}
}
cb(k, err)
@@ -84,11 +84,11 @@ func (f *fakeDatastore) PutMulti(keys []*Key, vals []PropertyMap, cb PutMultiCB)
}
func (f *fakeDatastore) GetMulti(keys []*Key, _meta MultiMetaGetter, cb GetMultiCB) error {
- if keys[0].Last().Kind == "FailAll" {
+ if keys[0].Kind() == "FailAll" {
return errors.New("GetMulti fail all")
}
for i, k := range keys {
- if k.Last().Kind == "Fail" {
+ if k.Kind() == "Fail" {
cb(nil, errors.New("GetMulti fail"))
} else {
cb(PropertyMap{"Value": {MkProperty(i + 1)}}, nil)
@@ -98,11 +98,11 @@ func (f *fakeDatastore) GetMulti(keys []*Key, _meta MultiMetaGetter, cb GetMulti
}
func (f *fakeDatastore) DeleteMulti(keys []*Key, cb DeleteMultiCB) error {
- if keys[0].Last().Kind == "FailAll" {
+ if keys[0].Kind() == "FailAll" {
return errors.New("DeleteMulti fail all")
}
for _, k := range keys {
- if k.Last().Kind == "Fail" {
+ if k.Kind() == "Fail" {
cb(errors.New("DeleteMulti fail"))
} else {
cb(nil)
@@ -423,7 +423,7 @@ func TestPut(t *testing.T) {
pm := PropertyMap{"Value": {MkProperty(0)}, "$kind": {MkPropertyNI("Pmap")}}
So(ds.Put(pm), ShouldBeNil)
- So(ds.KeyForObj(pm).Last().IntID, ShouldEqual, 1)
+ So(ds.KeyForObj(pm).IntID(), ShouldEqual, 1)
})
Convey("[]P (map)", func() {
@@ -688,7 +688,7 @@ func TestGetAll(t *testing.T) {
for i, o := range output {
k, err := o.GetMeta("key")
So(err, ShouldBeNil)
- So(k.(*Key).Last().IntID, ShouldEqual, i+1)
+ So(k.(*Key).IntID(), ShouldEqual, i+1)
So(o["Value"][0].Value().(int64), ShouldEqual, i)
}
})
@@ -712,7 +712,7 @@ func TestGetAll(t *testing.T) {
o := *op
k, err := o.GetMeta("key")
So(err, ShouldBeNil)
- So(k.(*Key).Last().IntID, ShouldEqual, i+1)
+ So(k.(*Key).IntID(), ShouldEqual, i+1)
So(o["Value"][0].Value().(int64), ShouldEqual, i)
}
})
@@ -722,7 +722,7 @@ func TestGetAll(t *testing.T) {
So(ds.GetAll(q, &output), ShouldBeNil)
So(len(output), ShouldEqual, 5)
for i, k := range output {
- So(k.Last().IntID, ShouldEqual, i+1)
+ So(k.IntID(), ShouldEqual, i+1)
}
})
@@ -828,7 +828,7 @@ func TestRun(t *testing.T) {
So(ds.Run(q, func(pm *PropertyMap, _ CursorCB) bool {
k, err := pm.GetMeta("key")
So(err, ShouldBeNil)
- So(k.(*Key).Last().IntID, ShouldEqual, i+1)
+ So(k.(*Key).IntID(), ShouldEqual, i+1)
So((*pm)["Value"][0].Value(), ShouldEqual, i)
i++
return true
@@ -861,7 +861,7 @@ func TestRun(t *testing.T) {
So(ds.Run(q, func(pm PropertyMap, _ CursorCB) bool {
k, err := pm.GetMeta("key")
So(err, ShouldBeNil)
- So(k.(*Key).Last().IntID, ShouldEqual, i+1)
+ So(k.(*Key).IntID(), ShouldEqual, i+1)
So(pm["Value"][0].Value(), ShouldEqual, i)
i++
return true
@@ -871,7 +871,7 @@ func TestRun(t *testing.T) {
Convey("Key", func() {
i := 0
So(ds.Run(q, func(k *Key, _ CursorCB) bool {
- So(k.Last().IntID, ShouldEqual, i+1)
+ So(k.IntID(), ShouldEqual, i+1)
i++
return true
}), ShouldBeNil)
« no previous file with comments | « impl/prod/raw_datastore.go ('k') | service/datastore/key.go » ('j') | service/datastore/key.go » ('J')

Powered by Google App Engine
This is Rietveld 408576698