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

Unified Diff: go/src/infra/gae/libs/wrapper/memory/key_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/key.go ('k') | go/src/infra/gae/libs/wrapper/memory/memcache.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/key_test.go
diff --git a/go/src/infra/gae/libs/wrapper/memory/key_test.go b/go/src/infra/gae/libs/wrapper/memory/key_test.go
new file mode 100644
index 0000000000000000000000000000000000000000..3bb9f8e994a2932dc82f7aec2ced6264ecff54d6
--- /dev/null
+++ b/go/src/infra/gae/libs/wrapper/memory/key_test.go
@@ -0,0 +1,51 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package memory
+
+import (
+ "bytes"
+ "fmt"
+ "infra/gae/libs/wrapper"
+ "testing"
+
+ . "github.com/smartystreets/goconvey/convey"
+ "golang.org/x/net/context"
+
+ "appengine/datastore"
+)
+
+func shouldEqualKey(ai interface{}, bis ...interface{}) string {
+ if len(bis) != 1 {
+ return "too many bees!"
+ }
+ a, b := ai.(*datastore.Key), bis[0].(*datastore.Key)
+ if !a.Equal(b) {
+ return fmt.Sprintf("Expected: %s\nActual: %s", b.String(), a.String())
+ }
+ return ""
+}
+
+func TestKeyBinaryStuff(t *testing.T) {
+ t.Parallel()
+
+ Convey("Key binary encoding", t, func() {
+ c := Use(context.Background())
+ c, err := wrapper.GetGI(c).Namespace("bobspace")
+ So(err, ShouldBeNil)
+ ds := wrapper.GetDS(c)
+
+ k := ds.NewKey("Bunny", "", 10, ds.NewKey("Parent", "Cat", 0, nil))
+ So(k.Namespace(), ShouldEqual, "bobspace")
+
+ b := &bytes.Buffer{}
+ writeKey(b, withNS, k)
+
+ newk, err := readKey(b, withNS, "")
+ So(err, ShouldBeNil)
+ So(k.Namespace(), ShouldEqual, "bobspace")
+ So(newk, shouldEqualKey, k)
+ So(b.Bytes(), ShouldBeEmpty)
+ })
+}
« no previous file with comments | « go/src/infra/gae/libs/wrapper/memory/key.go ('k') | go/src/infra/gae/libs/wrapper/memory/memcache.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698