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

Function TestSetRequest

v2/memcache/memcache_test.go:158–191  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

156}
157
158func TestSetRequest(t *testing.T) {
159 var apiItem = &Item{
160 Key: "lyric",
161 Value: []byte("Where the buffalo roam"),
162 }
163
164 serviceCalled := false
165
166 c := aetesting.FakeSingleContext(t, "memcache", "Set", func(req *pb.MemcacheSetRequest, _ *pb.MemcacheSetResponse) error {
167 // Test request.
168 if n := len(req.Item); n != 1 {
169 t.Errorf("got %d want 1", n)
170 return nil
171 }
172 pbItem := req.Item[0]
173 if k := string(pbItem.Key); k != apiItem.Key {
174 t.Errorf("got %q want %q", k, apiItem.Key)
175 }
176 if v := string(pbItem.Value); v != string(apiItem.Value) {
177 t.Errorf("got %q want %q", v, string(apiItem.Value))
178 }
179 if p := *pbItem.SetPolicy; p != pb.MemcacheSetRequest_SET {
180 t.Errorf("got %v want %v", p, pb.MemcacheSetRequest_SET)
181 }
182
183 serviceCalled = true
184 return nil
185 })
186
187 Set(c, apiItem)
188 if !serviceCalled {
189 t.Error("Service was not called as expected")
190 }
191}
192
193func TestSetResponse(t *testing.T) {
194 c := aetesting.FakeSingleContext(t, "memcache", "Set", func(_ *pb.MemcacheSetRequest, res *pb.MemcacheSetResponse) error {

Callers

nothing calls this directly

Calls 3

FakeSingleContextFunction · 0.92
SetFunction · 0.70
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…