(t *testing.T)
| 248 | } |
| 249 | |
| 250 | func TestStripCacheTrackingFields(t *testing.T) { |
| 251 | tests := []struct { |
| 252 | name string |
| 253 | in []byte |
| 254 | want []byte |
| 255 | }{ |
| 256 | { |
| 257 | name: "first field", |
| 258 | in: []byte(`{"__gj_id":1,"id":1}`), |
| 259 | want: []byte(`{"id":1}`), |
| 260 | }, |
| 261 | { |
| 262 | name: "nested duplicate values", |
| 263 | in: []byte(`{"data":{"users":{"__gj_id":1,"id":1,"posts":[{"__gj_id":1,"id":1},{"id":2,"__gj_id":2}]}}}`), |
| 264 | want: []byte(`{"data":{"users":{"id":1,"posts":[{"id":1},{"id":2}]}}}`), |
| 265 | }, |
| 266 | { |
| 267 | name: "no tracking field", |
| 268 | in: []byte(`{"data":{"users":{"id":1}}}`), |
| 269 | want: []byte(`{"data":{"users":{"id":1}}}`), |
| 270 | }, |
| 271 | } |
| 272 | |
| 273 | for _, tt := range tests { |
| 274 | t.Run(tt.name, func(t *testing.T) { |
| 275 | got, err := stripCacheTrackingFields(tt.in) |
| 276 | if err != nil { |
| 277 | t.Fatal(err) |
| 278 | } |
| 279 | if !bytes.Equal(got, tt.want) { |
| 280 | t.Fatalf("got %s, want %s", got, tt.want) |
| 281 | } |
| 282 | }) |
| 283 | } |
| 284 | } |
| 285 | |
| 286 | func TestResponseProcessor_SingleObject(t *testing.T) { |
| 287 | // Create qcode with one selection for "users" table |
nothing calls this directly
no test coverage detected