MCPcopy Create free account
hub / github.com/golang/appengine / TestNamespaceResetting

Function TestNamespaceResetting

memcache/memcache_test.go:215–248  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

213}
214
215func TestNamespaceResetting(t *testing.T) {
216 namec := make(chan *string, 1)
217 c0 := aetesting.FakeSingleContext(t, "memcache", "Get", func(req *pb.MemcacheGetRequest, res *pb.MemcacheGetResponse) error {
218 namec <- req.NameSpace
219 return errRPC
220 })
221
222 // Check that wrapping c0 in a namespace twice works correctly.
223 c1, err := appengine.Namespace(c0, "A")
224 if err != nil {
225 t.Fatalf("appengine.Namespace: %v", err)
226 }
227 c2, err := appengine.Namespace(c1, "") // should act as the original context
228 if err != nil {
229 t.Fatalf("appengine.Namespace: %v", err)
230 }
231
232 Get(c0, "key")
233 if ns := <-namec; ns != nil {
234 t.Errorf(`Get with c0: ns = %q, want nil`, *ns)
235 }
236
237 Get(c1, "key")
238 if ns := <-namec; ns == nil {
239 t.Error(`Get with c1: ns = nil, want "A"`)
240 } else if *ns != "A" {
241 t.Errorf(`Get with c1: ns = %q, want "A"`, *ns)
242 }
243
244 Get(c2, "key")
245 if ns := <-namec; ns != nil {
246 t.Errorf(`Get with c2: ns = %q, want nil`, *ns)
247 }
248}
249
250func TestGetMultiEmpty(t *testing.T) {
251 serviceCalled := false

Callers

nothing calls this directly

Calls 4

FakeSingleContextFunction · 0.92
NamespaceFunction · 0.92
GetFunction · 0.70
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…