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

Unified Diff: impl/memory/datastore_query_execution_test.go

Issue 1844183003: Don't filter "Stop" error in raw interface. (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/gae@master
Patch Set: Count filter doesn't count Stop as error. Created 4 years, 9 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') | impl/memory/gkvlite_iter.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: impl/memory/datastore_query_execution_test.go
diff --git a/impl/memory/datastore_query_execution_test.go b/impl/memory/datastore_query_execution_test.go
index 5d43343d3515df2cc3a1baca0773f9c43c2ea13c..6f7183b20e0ede2bbbacd208e425f059451b980c 100644
--- a/impl/memory/datastore_query_execution_test.go
+++ b/impl/memory/datastore_query_execution_test.go
@@ -362,13 +362,13 @@ var queryExecutionTests = []qExTest{
So(err, ShouldBeNil)
return ds.Stop
})
- So(err, ShouldBeNil)
+ So(err, shouldBeSuccessful)
err = data.Run(q.Start(curs), func(pm ds.PropertyMap) error {
So(pm, ShouldResemble, stage1Data[2])
return ds.Stop
})
- So(err, ShouldBeNil)
+ So(err, shouldBeSuccessful)
},
func(c context.Context) {
@@ -519,18 +519,18 @@ func TestQueryExecution(t *testing.T) {
err := runner(func(c context.Context) error {
data := ds.Get(c)
count, err := data.Count(expect.q)
- So(err, ShouldBeNil)
+ So(err, shouldBeSuccessful)
So(count, ShouldEqual, expect.count)
rslt := []*ds.Key(nil)
- So(data.GetAll(expect.q, &rslt), ShouldBeNil)
+ So(data.GetAll(expect.q, &rslt), shouldBeSuccessful)
So(len(rslt), ShouldEqual, len(expect.keys))
for i, r := range rslt {
So(r, ShouldResemble, expect.keys[i])
}
return nil
}, &ds.TransactionOptions{XG: true})
- So(err, ShouldBeNil)
+ So(err, shouldBeSuccessful)
})
}
@@ -539,18 +539,18 @@ func TestQueryExecution(t *testing.T) {
err := runner(func(c context.Context) error {
data := ds.Get(c)
count, err := data.Count(expect.q)
- So(err, ShouldBeNil)
+ So(err, shouldBeSuccessful)
So(count, ShouldEqual, expect.count)
rslt := []ds.PropertyMap(nil)
- So(data.GetAll(expect.q, &rslt), ShouldBeNil)
+ So(data.GetAll(expect.q, &rslt), shouldBeSuccessful)
So(len(rslt), ShouldEqual, len(expect.get))
for i, r := range rslt {
So(r, ShouldResemble, expect.get[i])
}
return nil
}, &ds.TransactionOptions{XG: true})
- So(err, ShouldBeNil)
+ So(err, shouldBeSuccessful)
})
}
}
@@ -579,12 +579,12 @@ func TestQueryExecution(t *testing.T) {
So(data.Put(pmap("$key", key("Kind", 1), Next,
"Val", 1, 2, 3, Next,
"Extra", "hello",
- )), ShouldBeNil)
+ )), shouldBeSuccessful)
So(data.Put(pmap("$key", key("Kind", 2), Next,
"Val", 2, 3, 9, Next,
"Extra", "ace", "hello", "there",
- )), ShouldBeNil)
+ )), shouldBeSuccessful)
q := nq("Kind").Gt("Val", 2).Order("Val", "Extra")
@@ -594,7 +594,25 @@ func TestQueryExecution(t *testing.T) {
testing.AutoIndex(true)
count, err = data.Count(q)
- So(err, ShouldBeNil)
+ So(err, shouldBeSuccessful)
So(count, ShouldEqual, 2)
})
}
+
+func shouldBeSuccessful(actual interface{}, expected ...interface{}) string {
+ if len(expected) != 0 {
+ return "no expected values permitted"
+ }
+ if actual == nil {
+ return ""
+ }
+
+ v, ok := actual.(error)
+ if !ok {
+ return fmt.Sprintf("type of 'actual' must be error, not %T", actual)
+ }
+ if v == nil || v == ds.Stop {
+ return ""
+ }
+ return fmt.Sprintf("expected success value, not %v", v)
+}
« no previous file with comments | « impl/memory/datastore_data.go ('k') | impl/memory/gkvlite_iter.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698