| Index: service/datastore/datastore_test.go
|
| diff --git a/service/datastore/datastore_test.go b/service/datastore/datastore_test.go
|
| index b4a2756204897c7ad5d75987f946aa6ff5caecfe..829346824f91f31686639180ff084d9663fc1d9b 100644
|
| --- a/service/datastore/datastore_test.go
|
| +++ b/service/datastore/datastore_test.go
|
| @@ -760,15 +760,15 @@ func TestRun(t *testing.T) {
|
|
|
| Convey("bad", func() {
|
| Convey("bad proto type", func() {
|
| - So(ds.Run(q, 100, func(obj interface{}, _ func() (Cursor, error)) bool {
|
| + So(ds.Run(q, func(v int, _ CursorCB) bool {
|
| panic("never here!")
|
| - }).Error(), ShouldContainSubstring, "invalid Run proto type")
|
| + }).Error(), ShouldContainSubstring, "cb has a bad first argument")
|
| })
|
|
|
| Convey("early abort on error", func() {
|
| rq := q.(*fakeQuery).Fail(3)
|
| i := 0
|
| - So(ds.Run(rq, CommonStruct{}, func(_ interface{}, _ func() (Cursor, error)) bool {
|
| + So(ds.Run(rq, func(c CommonStruct, _ CursorCB) bool {
|
| i++
|
| return true
|
| }).Error(), ShouldEqual, "Query fail")
|
| @@ -776,7 +776,7 @@ func TestRun(t *testing.T) {
|
| })
|
|
|
| Convey("return error on serialization failure", func() {
|
| - So(ds.Run(q, permaBad{}, func(_ interface{}, _ func() (Cursor, error)) bool {
|
| + So(ds.Run(q, func(_ permaBad, _ CursorCB) bool {
|
| panic("never here")
|
| }).Error(), ShouldEqual, "permaBad")
|
| })
|
| @@ -785,8 +785,7 @@ func TestRun(t *testing.T) {
|
| Convey("ok", func() {
|
| Convey("*S", func() {
|
| i := 0
|
| - So(ds.Run(q, (*CommonStruct)(nil), func(obj interface{}, _ func() (Cursor, error)) bool {
|
| - cs := obj.(*CommonStruct)
|
| + So(ds.Run(q, func(cs *CommonStruct, _ CursorCB) bool {
|
| So(cs.ID, ShouldEqual, i+1)
|
| So(cs.Value, ShouldEqual, i)
|
| i++
|
| @@ -796,8 +795,7 @@ func TestRun(t *testing.T) {
|
|
|
| Convey("*P", func() {
|
| i := 0
|
| - So(ds.Run(q.Limit(12), (*FakePLS)(nil), func(obj interface{}, _ func() (Cursor, error)) bool {
|
| - fpls := obj.(*FakePLS)
|
| + So(ds.Run(q.Limit(12), func(fpls *FakePLS, _ CursorCB) bool {
|
| So(fpls.gotLoaded, ShouldBeTrue)
|
| if i == 10 {
|
| So(fpls.StringID, ShouldEqual, "eleven")
|
| @@ -812,12 +810,11 @@ func TestRun(t *testing.T) {
|
|
|
| Convey("*P (map)", func() {
|
| i := 0
|
| - So(ds.Run(q, (*PropertyMap)(nil), func(obj interface{}, _ func() (Cursor, error)) bool {
|
| - pm := *obj.(*PropertyMap)
|
| + So(ds.Run(q, func(pm *PropertyMap, _ CursorCB) bool {
|
| k, err := pm.GetMeta("key")
|
| So(err, ShouldBeNil)
|
| So(k.(Key).IntID(), ShouldEqual, i+1)
|
| - So(pm["Value"][0].Value(), ShouldEqual, i)
|
| + So((*pm)["Value"][0].Value(), ShouldEqual, i)
|
| i++
|
| return true
|
| }), ShouldBeNil)
|
| @@ -825,8 +822,7 @@ func TestRun(t *testing.T) {
|
|
|
| Convey("S", func() {
|
| i := 0
|
| - So(ds.Run(q, CommonStruct{}, func(obj interface{}, _ func() (Cursor, error)) bool {
|
| - cs := obj.(CommonStruct)
|
| + So(ds.Run(q, func(cs CommonStruct, _ CursorCB) bool {
|
| So(cs.ID, ShouldEqual, i+1)
|
| So(cs.Value, ShouldEqual, i)
|
| i++
|
| @@ -836,8 +832,7 @@ func TestRun(t *testing.T) {
|
|
|
| Convey("P", func() {
|
| i := 0
|
| - So(ds.Run(q, FakePLS{}, func(obj interface{}, _ func() (Cursor, error)) bool {
|
| - fpls := obj.(FakePLS)
|
| + So(ds.Run(q, func(fpls FakePLS, _ CursorCB) bool {
|
| So(fpls.gotLoaded, ShouldBeTrue)
|
| So(fpls.IntID, ShouldEqual, i+1)
|
| So(fpls.Value, ShouldEqual, i)
|
| @@ -848,8 +843,7 @@ func TestRun(t *testing.T) {
|
|
|
| Convey("P (map)", func() {
|
| i := 0
|
| - So(ds.Run(q, (PropertyMap)(nil), func(obj interface{}, _ func() (Cursor, error)) bool {
|
| - pm := obj.(PropertyMap)
|
| + So(ds.Run(q, func(pm PropertyMap, _ CursorCB) bool {
|
| k, err := pm.GetMeta("key")
|
| So(err, ShouldBeNil)
|
| So(k.(Key).IntID(), ShouldEqual, i+1)
|
| @@ -861,8 +855,8 @@ func TestRun(t *testing.T) {
|
|
|
| Convey("*Key", func() {
|
| i := 0
|
| - So(ds.Run(q, (*Key)(nil), func(obj interface{}, _ func() (Cursor, error)) bool {
|
| - So(obj.(Key).IntID(), ShouldEqual, i+1)
|
| + So(ds.Run(q, func(k Key, _ CursorCB) bool {
|
| + So(k.IntID(), ShouldEqual, i+1)
|
| i++
|
| return true
|
| }), ShouldBeNil)
|
|
|