| Index: impl/memory/testing_utils_test.go
|
| diff --git a/impl/memory/testing_utils_test.go b/impl/memory/testing_utils_test.go
|
| index 42089586997a7def196ccc522fddec056cc7f6d6..513c0985098b1622968f578a96c646ecffdd3400 100644
|
| --- a/impl/memory/testing_utils_test.go
|
| +++ b/impl/memory/testing_utils_test.go
|
| @@ -7,6 +7,7 @@ package memory
|
| import (
|
| "bytes"
|
| "fmt"
|
| + "strings"
|
| "time"
|
|
|
| ds "github.com/luci/gae/service/datastore"
|
| @@ -15,7 +16,57 @@ import (
|
| "github.com/luci/luci-go/common/cmpbin"
|
| )
|
|
|
| -type kv struct{ k, v []byte }
|
| +func init() {
|
| + serializationDeterministic = true
|
| + serialize.WritePropertyMapDeterministic = true
|
| +}
|
| +
|
| +var NEXT_STR = "NEXT MARKER"
|
| +var NEXT = &NEXT_STR
|
| +
|
| +// Use like:
|
| +// pmap(
|
| +// "prop", "val", 0, 100, NEXT,
|
| +// "other", "val", 0, 100, NEXT,
|
| +// )
|
| +//
|
| +func pmap(stuff ...interface{}) ds.PropertyMap {
|
| + ret := ds.PropertyMap{}
|
| +
|
| + nom := func() interface{} {
|
| + if len(stuff) > 0 {
|
| + ret := stuff[0]
|
| + stuff = stuff[1:]
|
| + return ret
|
| + }
|
| + return nil
|
| + }
|
| +
|
| + for len(stuff) > 0 {
|
| + pname := nom().(string)
|
| + if pname[0] == '$' || (strings.HasPrefix(pname, "__") && strings.HasSuffix(pname, "__")) {
|
| + for len(stuff) > 0 && stuff[0] != NEXT {
|
| + ret[pname] = append(ret[pname], propNI(nom()))
|
| + }
|
| + } else {
|
| + for len(stuff) > 0 && stuff[0] != NEXT {
|
| + ret[pname] = append(ret[pname], prop(nom()))
|
| + }
|
| + }
|
| + nom()
|
| + }
|
| +
|
| + 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"}
|
| + }
|
| + return &queryImpl{kind: "Foo", ns: "ns"}
|
| +}
|
|
|
| func indx(kind string, orders ...string) *ds.IndexDefinition {
|
| ancestor := false
|
| @@ -51,7 +102,7 @@ func key(kind string, id interface{}, parent ...ds.Key) ds.Key {
|
| case int:
|
| return dskey.New(globalAppID, "ns", kind, "", int64(x), p)
|
| default:
|
| - panic(fmt.Errorf("what the %T: %v", id, id))
|
| + return dskey.New(globalAppID, "ns", kind, "invalid", 100, p)
|
| }
|
| }
|
|
|
| @@ -85,6 +136,8 @@ func cat(bytethings ...interface{}) []byte {
|
| serialize.WriteKey(buf, serialize.WithoutContext, x)
|
| case *ds.IndexDefinition:
|
| serialize.WriteIndexDefinition(buf, *x)
|
| + case ds.Property:
|
| + serialize.WriteProperty(buf, serialize.WithoutContext, x)
|
| default:
|
| panic(fmt.Errorf("I don't know how to deal with %T: %#v", thing, thing))
|
| }
|
|
|