(t *testing.T)
| 156 | } |
| 157 | |
| 158 | func 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 | |
| 193 | func TestSetResponse(t *testing.T) { |
| 194 | c := aetesting.FakeSingleContext(t, "memcache", "Set", func(_ *pb.MemcacheSetRequest, res *pb.MemcacheSetResponse) error { |
nothing calls this directly
no test coverage detected
searching dependent graphs…