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

Side by Side Diff: go/src/infra/gae/libs/wrapper/memory/key_test.go

Issue 1222903002: Refactor current GAE abstraction library to be free of the SDK* (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: more fixes 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 package memory
6
7 import (
8 "bytes"
9 "fmt"
10 "infra/gae/libs/wrapper"
11 "testing"
12
13 . "github.com/smartystreets/goconvey/convey"
14 "golang.org/x/net/context"
15
16 "appengine/datastore"
17 )
18
19 func shouldEqualKey(ai interface{}, bis ...interface{}) string {
20 if len(bis) != 1 {
21 return "too many bees!"
22 }
23 a, b := ai.(*datastore.Key), bis[0].(*datastore.Key)
24 if !a.Equal(b) {
25 return fmt.Sprintf("Expected: %s\nActual: %s", b.String(), a.S tring())
26 }
27 return ""
28 }
29
30 func TestKeyBinaryStuff(t *testing.T) {
31 t.Parallel()
32
33 Convey("Key binary encoding", t, func() {
34 c := Use(context.Background())
35 c, err := wrapper.GetGI(c).Namespace("bobspace")
36 So(err, ShouldBeNil)
37 ds := wrapper.GetDS(c)
38
39 k := ds.NewKey("Bunny", "", 10, ds.NewKey("Parent", "Cat", 0, ni l))
40 So(k.Namespace(), ShouldEqual, "bobspace")
41
42 b := &bytes.Buffer{}
43 writeKey(b, withNS, k)
44
45 newk, err := readKey(b, withNS, "")
46 So(err, ShouldBeNil)
47 So(k.Namespace(), ShouldEqual, "bobspace")
48 So(newk, shouldEqualKey, k)
49 So(b.Bytes(), ShouldBeEmpty)
50 })
51 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698