| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package memory | 5 package memory |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "bytes" | 8 "bytes" |
| 9 "fmt" | 9 "fmt" |
| 10 "infra/gae/libs/wrapper" | 10 "infra/gae/libs/wrapper" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 if !a.Equal(b) { | 24 if !a.Equal(b) { |
| 25 return fmt.Sprintf("Expected: %s\nActual: %s", b.String(), a.S
tring()) | 25 return fmt.Sprintf("Expected: %s\nActual: %s", b.String(), a.S
tring()) |
| 26 } | 26 } |
| 27 return "" | 27 return "" |
| 28 } | 28 } |
| 29 | 29 |
| 30 func TestKeyBinaryStuff(t *testing.T) { | 30 func TestKeyBinaryStuff(t *testing.T) { |
| 31 t.Parallel() | 31 t.Parallel() |
| 32 | 32 |
| 33 Convey("Key binary encoding", t, func() { | 33 Convey("Key binary encoding", t, func() { |
| 34 » » c := Use(Enable(context.Background())) | 34 » » c := Use(context.Background()) |
| 35 c, err := wrapper.GetGI(c).Namespace("bobspace") | 35 c, err := wrapper.GetGI(c).Namespace("bobspace") |
| 36 So(err, ShouldBeNil) | 36 So(err, ShouldBeNil) |
| 37 ds := wrapper.GetDS(c) | 37 ds := wrapper.GetDS(c) |
| 38 | 38 |
| 39 k := ds.NewKey("Bunny", "", 10, ds.NewKey("Parent", "Cat", 0, ni
l)) | 39 k := ds.NewKey("Bunny", "", 10, ds.NewKey("Parent", "Cat", 0, ni
l)) |
| 40 So(k.Namespace(), ShouldEqual, "bobspace") | 40 So(k.Namespace(), ShouldEqual, "bobspace") |
| 41 | 41 |
| 42 b := &bytes.Buffer{} | 42 b := &bytes.Buffer{} |
| 43 writeKey(b, withNS, k) | 43 writeKey(b, withNS, k) |
| 44 | 44 |
| 45 newk, err := readKey(b, withNS) | 45 newk, err := readKey(b, withNS) |
| 46 So(err, ShouldBeNil) | 46 So(err, ShouldBeNil) |
| 47 So(k.Namespace(), ShouldEqual, "bobspace") | 47 So(k.Namespace(), ShouldEqual, "bobspace") |
| 48 So(newk, shouldEqualKey, k) | 48 So(newk, shouldEqualKey, k) |
| 49 So(b.Bytes(), ShouldBeEmpty) | 49 So(b.Bytes(), ShouldBeEmpty) |
| 50 }) | 50 }) |
| 51 } | 51 } |
| OLD | NEW |