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

Side by Side Diff: impl/memory/memcache_test.go

Issue 1916463004: impl/memory: Disallow empty namespace. (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/gae@master
Patch Set: Rbase. Created 4 years, 8 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
« no previous file with comments | « impl/memory/memcache.go ('k') | impl/memory/taskqueue.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 }
OLDNEW
« no previous file with comments | « impl/memory/memcache.go ('k') | impl/memory/taskqueue.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698