From f7d20ef0c98cab10d0d1443d48755e0deea58b66 Mon Sep 17 00:00:00 2001 From: Grey Newell Date: Wed, 8 Apr 2026 16:36:26 -0400 Subject: [PATCH] Fix makeGraph() fixture using uppercase CALLS rel type MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The shared test fixture used CALLS (uppercase) while production code only handles lowercase relationship types ("calls", "contains_call"). This meant any future test using makeGraph() and checking callers would silently get empty results — a silent trap for new tests. Also adds TestSearch_SharedFixtureCallers to guard this invariant: it verifies that fn3("main") →calls→ fn1("handleRequest") is correctly indexed so "handleRequest" shows "main" as a caller. Co-Authored-By: Claude Sonnet 4.6 --- internal/find/handler_test.go | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/internal/find/handler_test.go b/internal/find/handler_test.go index bc9b65f..8f3bfa1 100644 --- a/internal/find/handler_test.go +++ b/internal/find/handler_test.go @@ -77,6 +77,21 @@ func TestSearch_SortedByKindThenName(t *testing.T) { } } +func TestSearch_SharedFixtureCallers(t *testing.T) { + // makeGraph() has fn3("main") --calls--> fn1("handleRequest"). + // Searching for "handleRequest" should show "main" as a caller. + // This test guards against the makeGraph() fixture using uppercase CALLS. + g := makeGraph() + matches := search(g, "handleRequest", "") + if len(matches) != 1 { + t.Fatalf("want 1 match, got %d", len(matches)) + } + m := matches[0] + if len(m.Callers) != 1 || m.Callers[0] != "main" { + t.Errorf("callers: want [main], got %v", m.Callers) + } +} + func TestSearch_CallersAndCallees(t *testing.T) { // caller calls target calls callee g := &api.Graph{ @@ -202,7 +217,7 @@ func makeGraph() *api.Graph { {ID: "fn3", Labels: []string{"Function"}, Properties: map[string]any{"name": "main"}}, }, Relationships: []api.Relationship{ - {ID: "r1", Type: "CALLS", StartNode: "fn3", EndNode: "fn1"}, + {ID: "r1", Type: "calls", StartNode: "fn3", EndNode: "fn1"}, }, } }