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

Unified Diff: go/src/infra/gae/libs/wrapper/memory/testing_utils_test.go

Issue 1230303003: Revert "Refactor current GAE abstraction library to be free of the SDK*" (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Created 5 years, 5 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 | « go/src/infra/gae/libs/wrapper/memory/taskqueue_test.go ('k') | go/src/infra/gae/libs/wrapper/taskqueue.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: go/src/infra/gae/libs/wrapper/memory/testing_utils_test.go
diff --git a/go/src/infra/gae/libs/gae/memory/testing_utils_test.go b/go/src/infra/gae/libs/wrapper/memory/testing_utils_test.go
similarity index 58%
rename from go/src/infra/gae/libs/gae/memory/testing_utils_test.go
rename to go/src/infra/gae/libs/wrapper/memory/testing_utils_test.go
index 81fdedbf46d2923625109b743eba0903397c4847..59fc990dbf2174e07c9447c6be1615fbbe7071fe 100644
--- a/go/src/infra/gae/libs/gae/memory/testing_utils_test.go
+++ b/go/src/infra/gae/libs/wrapper/memory/testing_utils_test.go
@@ -7,10 +7,10 @@ package memory
import (
"bytes"
"fmt"
+ "reflect"
"time"
- "infra/gae/libs/gae"
- "infra/gae/libs/gae/helper"
+ "appengine/datastore"
"github.com/luci/luci-go/common/cmpbin"
)
@@ -35,30 +35,43 @@ func indx(kind string, orders ...string) *qIndex {
return ret
}
-func prop(val interface{}, noIndex ...bool) (ret gae.DSProperty) {
- ni := false
+func pl(props ...datastore.Property) *propertyList {
+ return (*propertyList)(&props)
+}
+
+func prop(name string, val interface{}, noIndex ...bool) (ret datastore.Property) {
+ ret.Name = name
+ ret.Value = val
if len(noIndex) > 0 {
- ni = noIndex[0]
- }
- if err := ret.SetValue(val, ni); err != nil {
- panic(err)
+ ret.NoIndex = noIndex[0]
}
return
}
-func key(kind string, id interface{}, parent ...gae.DSKey) gae.DSKey {
- p := gae.DSKey(nil)
- if len(parent) > 0 {
- p = parent[0]
- }
+func key(kind string, id interface{}, parent ...*datastore.Key) *datastore.Key {
+ stringID := ""
+ intID := int64(0)
switch x := id.(type) {
case string:
- return helper.NewDSKey(globalAppID, "ns", kind, x, 0, p)
+ stringID = x
case int:
- return helper.NewDSKey(globalAppID, "ns", kind, "", int64(x), p)
+ intID = int64(x)
default:
panic(fmt.Errorf("what the %T: %v", id, id))
}
+ par := (*datastore.Key)(nil)
+ if len(parent) > 0 {
+ par = parent[0]
+ }
+ return newKey("ns", kind, stringID, intID, par)
+}
+
+func mustLoadLocation(loc string) *time.Location {
+ if z, err := time.LoadLocation(loc); err != nil {
+ panic(err)
+ } else {
+ return z
+ }
}
// cat is a convenience method for concatenating anything with an underlying
@@ -67,28 +80,22 @@ func cat(bytethings ...interface{}) []byte {
buf := &bytes.Buffer{}
for _, thing := range bytethings {
switch x := thing.(type) {
- case int64:
- cmpbin.WriteInt(buf, x)
- case int:
- cmpbin.WriteInt(buf, int64(x))
- case uint64:
- cmpbin.WriteUint(buf, x)
- case uint:
- cmpbin.WriteUint(buf, uint64(x))
+ case int, int64:
+ cmpbin.WriteInt(buf, reflect.ValueOf(x).Int())
+ case uint, uint64:
+ cmpbin.WriteUint(buf, reflect.ValueOf(x).Uint())
case float64:
- cmpbin.WriteFloat64(buf, x)
- case byte:
- buf.WriteByte(x)
- case gae.DSPropertyType:
- buf.WriteByte(byte(x))
+ writeFloat64(buf, x)
+ case byte, propValType:
+ buf.WriteByte(byte(reflect.ValueOf(x).Uint()))
+ case []byte, serializedPval:
+ buf.Write(reflect.ValueOf(x).Convert(byteSliceType).Interface().([]byte))
case string:
- cmpbin.WriteString(buf, x)
- case []byte:
- buf.Write(x)
+ writeString(buf, x)
case time.Time:
- helper.WriteTime(buf, x)
- case gae.DSKey:
- helper.WriteDSKey(buf, helper.WithoutContext, x)
+ writeTime(buf, x)
+ case *datastore.Key:
+ writeKey(buf, noNS, x)
case *qIndex:
x.WriteBinary(buf)
default:
« no previous file with comments | « go/src/infra/gae/libs/wrapper/memory/taskqueue_test.go ('k') | go/src/infra/gae/libs/wrapper/taskqueue.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698