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

Unified Diff: impl/memory/testing_utils_test.go

Issue 1355783002: Refactor keys and queries in datastore service and implementation. (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
Index: impl/memory/testing_utils_test.go
diff --git a/impl/memory/testing_utils_test.go b/impl/memory/testing_utils_test.go
index 513c0985098b1622968f578a96c646ecffdd3400..5b4ad38174b37783070395c183a5237828bafd3a 100644
--- a/impl/memory/testing_utils_test.go
+++ b/impl/memory/testing_utils_test.go
@@ -11,7 +11,6 @@ import (
"time"
ds "github.com/luci/gae/service/datastore"
- "github.com/luci/gae/service/datastore/dskey"
"github.com/luci/gae/service/datastore/serialize"
"github.com/luci/luci-go/common/cmpbin"
)
@@ -59,13 +58,12 @@ func pmap(stuff ...interface{}) ds.PropertyMap {
return ret
}
-func nq(kind_ns ...string) ds.Query {
- if len(kind_ns) == 2 {
- return &queryImpl{kind: kind_ns[0], ns: kind_ns[1]}
- } else if len(kind_ns) == 1 {
- return &queryImpl{kind: kind_ns[0], ns: "ns"}
+func nq(kindMaybe ...string) *ds.Query {
+ kind := "Foo"
+ if len(kindMaybe) == 1 {
+ kind = kindMaybe[0]
}
- return &queryImpl{kind: "Foo", ns: "ns"}
+ return ds.NewQuery(kind)
iannucci 2015/09/18 04:31:52 Querys no longer embed the namespace and appid ins
}
func indx(kind string, orders ...string) *ds.IndexDefinition {
@@ -91,19 +89,8 @@ var (
propNI = ds.MkPropertyNI
)
-func key(kind string, id interface{}, parent ...ds.Key) ds.Key {
iannucci 2015/09/18 04:31:52 I had like 5 copies of this function all over the
- p := ds.Key(nil)
- if len(parent) > 0 {
- p = parent[0]
- }
- switch x := id.(type) {
- case string:
- return dskey.New(globalAppID, "ns", kind, x, 0, p)
- case int:
- return dskey.New(globalAppID, "ns", kind, "", int64(x), p)
- default:
- return dskey.New(globalAppID, "ns", kind, "invalid", 100, p)
- }
+func key(elems ...interface{}) *ds.Key {
+ return ds.MakeKey(globalAppID, "ns", elems...)
}
// cat is a convenience method for concatenating anything with an underlying
@@ -132,7 +119,7 @@ func cat(bytethings ...interface{}) []byte {
buf.Write(x)
case time.Time:
serialize.WriteTime(buf, x)
- case ds.Key:
+ case *ds.Key:
serialize.WriteKey(buf, serialize.WithoutContext, x)
case *ds.IndexDefinition:
serialize.WriteIndexDefinition(buf, *x)

Powered by Google App Engine
This is Rietveld 408576698