MCPcopy
hub / github.com/dosco/graphjin / TestStripCacheTrackingFields

Function TestStripCacheTrackingFields

core/cache_response_test.go:250–284  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

248}
249
250func 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
286func TestResponseProcessor_SingleObject(t *testing.T) {
287 // Create qcode with one selection for "users" table

Callers

nothing calls this directly

Calls 1

stripCacheTrackingFieldsFunction · 0.85

Tested by

no test coverage detected