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

Function TestAddRequest

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

Source from the content-addressed store, hash-verified

82}
83
84func TestAddRequest(t *testing.T) {
85 var apiItem = &Item{
86 Key: "lyric",
87 Value: []byte("Oh, give me a home"),
88 }
89
90 serviceCalled := false
91
92 c := aetesting.FakeSingleContext(t, "memcache", "Set", func(req *pb.MemcacheSetRequest, _ *pb.MemcacheSetResponse) error {
93 // Test request.
94 pbItem := req.Item[0]
95 if k := string(pbItem.Key); k != apiItem.Key {
96 t.Errorf("got %q want %q", k, apiItem.Key)
97 }
98 if v := string(apiItem.Value); v != string(pbItem.Value) {
99 t.Errorf("got %q want %q", v, string(pbItem.Value))
100 }
101 if p := *pbItem.SetPolicy; p != pb.MemcacheSetRequest_ADD {
102 t.Errorf("got %v want %v", p, pb.MemcacheSetRequest_ADD)
103 }
104
105 serviceCalled = true
106 return nil
107 })
108
109 Add(c, apiItem)
110 if !serviceCalled {
111 t.Error("Service was not called as expected")
112 }
113}
114
115func TestAddResponseStored(t *testing.T) {
116 c := aetesting.FakeSingleContext(t, "memcache", "Set", func(_ *pb.MemcacheSetRequest, res *pb.MemcacheSetResponse) error {

Callers

nothing calls this directly

Calls 3

FakeSingleContextFunction · 0.92
AddFunction · 0.70
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…