(t *testing.T)
| 82 | } |
| 83 | |
| 84 | func 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 | |
| 115 | func TestAddResponseStored(t *testing.T) { |
| 116 | c := aetesting.FakeSingleContext(t, "memcache", "Set", func(_ *pb.MemcacheSetRequest, res *pb.MemcacheSetResponse) error { |
nothing calls this directly
no test coverage detected
searching dependent graphs…