Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion internal/find/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down Expand Up @@ -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"},
},
}
}
Loading