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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « impl/memory/memcache.go ('k') | impl/memory/taskqueue.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: impl/memory/memcache_test.go
diff --git a/impl/memory/memcache_test.go b/impl/memory/memcache_test.go
index 98803676d15c13853ce0032938fb7ff8e4a6e4b7..3fe6bf6d30579fa6dcade5be5b64083ee56b793b 100644
--- a/impl/memory/memcache_test.go
+++ b/impl/memory/memcache_test.go
@@ -8,6 +8,7 @@ import (
"testing"
"time"
+ infoS "github.com/luci/gae/service/info"
mcS "github.com/luci/gae/service/memcache"
"github.com/luci/luci-go/common/clock/testclock"
. "github.com/luci/luci-go/common/testing/assertions"
@@ -213,5 +214,27 @@ func TestMemcache(t *testing.T) {
So(getItm, ShouldResemble, testItem)
})
+ Convey("When adding an item to an unset namespace", func() {
+ _, has := infoS.Get(c).GetNamespace()
+ So(has, ShouldBeFalse)
+
+ item := mc.NewItem("foo").SetValue([]byte("heya"))
+ So(mc.Set(item), ShouldBeNil)
+
+ Convey("The item can be retrieved from the unset namespace.", func() {
+ got, err := mc.Get("foo")
+ So(err, ShouldBeNil)
+ So(got.Value(), ShouldResemble, []byte("heya"))
+ })
+
+ Convey("The item can be retrieved from a set, empty namespace.", func() {
+ // Now test with empty namespace.
+ c = infoS.Get(c).MustNamespace("")
+
+ got, err := mc.Get("foo")
+ So(err, ShouldBeNil)
+ So(got.Value(), ShouldResemble, []byte("heya"))
+ })
+ })
})
}
« 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