a06f331eb8
CI / benchmark (push) Has been skipped
install-script / posix-syntax (push) Successful in 6m1s
CI / build-onnx (push) Failing after 6m43s
init-smoke / dry-run (push) Failing after 15m57s
security / govulncheck (push) Has been cancelled
security / trivy-fs (push) Has been cancelled
CI / test (1.26, ubuntu-latest) (push) Has been cancelled
Scorecard supply-chain security / Scorecard analysis (push) Has been cancelled
CI / test (1.26, macos-latest) (push) Has been cancelled
CI / build-windows (push) Has been cancelled
CI / lint (push) Has been cancelled
install-script / powershell-syntax (push) Has been cancelled
install-script / install (macos-14) (push) Has been cancelled
install-script / install (ubuntu-latest) (push) Has been cancelled
44 lines
1.3 KiB
Go
44 lines
1.3 KiB
Go
package mcp
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/zzet/gortex/internal/graph"
|
|
"github.com/zzet/gortex/internal/query"
|
|
)
|
|
|
|
func TestEnrichSubGraphEdgesSetsVia(t *testing.T) {
|
|
sg := &query.SubGraph{Edges: []*graph.Edge{
|
|
{From: "a", To: "b", Kind: graph.EdgeCalls, Origin: graph.OriginASTInferred, Meta: map[string]any{"via": "observer.channel"}},
|
|
{From: "c", To: "d", Kind: graph.EdgeCalls, Origin: graph.OriginASTResolved}, // no via
|
|
}}
|
|
enrichSubGraphEdges(sg)
|
|
if sg.Edges[0].Via != "observer channel" {
|
|
t.Errorf("edge[0].Via = %q, want 'observer channel'", sg.Edges[0].Via)
|
|
}
|
|
if sg.Edges[1].Via != "" {
|
|
t.Errorf("edge[1].Via = %q, want empty (no via meta)", sg.Edges[1].Via)
|
|
}
|
|
}
|
|
|
|
func TestEncodeSubGraphEmitsViaColumn(t *testing.T) {
|
|
sg := &query.SubGraph{
|
|
Nodes: []*graph.Node{{ID: "a", Kind: graph.KindMethod, Name: "a"}, {ID: "b", Kind: graph.KindMethod, Name: "b"}},
|
|
Edges: []*graph.Edge{
|
|
{From: "a", To: "b", Kind: graph.EdgeCalls, Origin: graph.OriginASTInferred, Via: "observer channel"},
|
|
},
|
|
}
|
|
out, err := encodeSubGraph("walk_graph", sg)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
s := string(out)
|
|
if !strings.Contains(s, "via") {
|
|
t.Errorf("GCX subgraph edges header missing 'via' column:\n%s", s)
|
|
}
|
|
if !strings.Contains(s, "observer channel") {
|
|
t.Errorf("GCX subgraph missing via label 'observer channel':\n%s", s)
|
|
}
|
|
}
|