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 "testing" | 8 "testing" |
9 "time" | 9 "time" |
10 | 10 |
| 11 infoS "github.com/luci/gae/service/info" |
11 mcS "github.com/luci/gae/service/memcache" | 12 mcS "github.com/luci/gae/service/memcache" |
12 "github.com/luci/luci-go/common/clock/testclock" | 13 "github.com/luci/luci-go/common/clock/testclock" |
13 . "github.com/luci/luci-go/common/testing/assertions" | 14 . "github.com/luci/luci-go/common/testing/assertions" |
14 . "github.com/smartystreets/goconvey/convey" | 15 . "github.com/smartystreets/goconvey/convey" |
15 "golang.org/x/net/context" | 16 "golang.org/x/net/context" |
16 ) | 17 ) |
17 | 18 |
18 func TestMemcache(t *testing.T) { | 19 func TestMemcache(t *testing.T) { |
19 t.Parallel() | 20 t.Parallel() |
20 | 21 |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 So(mci.data.casID, ShouldEqual, 1) | 207 So(mci.data.casID, ShouldEqual, 1) |
207 | 208 |
208 testItem := &mcItem{ | 209 testItem := &mcItem{ |
209 key: "sup", | 210 key: "sup", |
210 value: []byte("cool"), | 211 value: []byte("cool"), |
211 CasID: 1, | 212 CasID: 1, |
212 } | 213 } |
213 So(getItm, ShouldResemble, testItem) | 214 So(getItm, ShouldResemble, testItem) |
214 }) | 215 }) |
215 | 216 |
| 217 Convey("When adding an item to an unset namespace", func() { |
| 218 _, has := infoS.Get(c).GetNamespace() |
| 219 So(has, ShouldBeFalse) |
| 220 |
| 221 item := mc.NewItem("foo").SetValue([]byte("heya")) |
| 222 So(mc.Set(item), ShouldBeNil) |
| 223 |
| 224 Convey("The item can be retrieved from the unset namespa
ce.", func() { |
| 225 got, err := mc.Get("foo") |
| 226 So(err, ShouldBeNil) |
| 227 So(got.Value(), ShouldResemble, []byte("heya")) |
| 228 }) |
| 229 |
| 230 Convey("The item can be retrieved from a set, empty name
space.", func() { |
| 231 // Now test with empty namespace. |
| 232 c = infoS.Get(c).MustNamespace("") |
| 233 |
| 234 got, err := mc.Get("foo") |
| 235 So(err, ShouldBeNil) |
| 236 So(got.Value(), ShouldResemble, []byte("heya")) |
| 237 }) |
| 238 }) |
216 }) | 239 }) |
217 } | 240 } |
OLD | NEW |