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

Function TestResponseProcessor_LargeArray

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

Source from the content-addressed store, hash-verified

690}
691
692func TestResponseProcessor_LargeArray(t *testing.T) {
693 qc := &qcode.QCode{
694 Selects: []qcode.Select{
695 {
696 Field: qcode.Field{
697 ID: 0,
698 ParentID: -1,
699 FieldName: "items",
700 },
701 Table: "items",
702 Ti: sdata.DBTable{Name: "items"},
703 },
704 },
705 }
706 rp := NewResponseProcessor(qc)
707
708 // Generate array with 1000 items
709 var items []map[string]interface{}
710 for i := 1; i <= 1000; i++ {
711 items = append(items, map[string]interface{}{
712 "id": i,
713 "__gj_id": i,
714 "name": "Item",
715 })
716 }
717 data := map[string]interface{}{"data": map[string]interface{}{"items": items}}
718 input, _ := json.Marshal(data)
719
720 cleaned, refs, err := rp.ProcessForCache(input)
721 if err != nil {
722 t.Errorf("unexpected error: %v", err)
723 }
724
725 // Should extract all refs
726 if len(refs) != 1000 {
727 t.Errorf("expected 1000 refs, got %d", len(refs))
728 }
729
730 // Verify __gj_id removed
731 var result map[string]interface{}
732 if err := json.Unmarshal(cleaned, &result); err != nil {
733 t.Errorf("failed to parse cleaned response: %v", err)
734 }
735 dataMap := result["data"].(map[string]interface{})
736 itemsResult := dataMap["items"].([]interface{})
737 if len(itemsResult) != 1000 {
738 t.Errorf("expected 1000 items in cleaned output, got %d", len(itemsResult))
739 }
740 // Check first item doesn't have __gj_id
741 firstItem := itemsResult[0].(map[string]interface{})
742 if _, hasGjId := firstItem["__gj_id"]; hasGjId {
743 t.Errorf("first item should not have __gj_id")
744 }
745}
746
747func TestExtractMutationRefs_Update(t *testing.T) {
748 qc := &qcode.QCode{

Callers

nothing calls this directly

Calls 2

ProcessForCacheMethod · 0.95
NewResponseProcessorFunction · 0.85

Tested by

no test coverage detected