Files
zzet--gortex/internal/query/suppress_empty_origin_test.go
wehub-resource-sync 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
chore: import upstream snapshot with attribution
2026-07-13 12:33:42 +08:00

31 lines
1.3 KiB
Go

package query
import (
"testing"
"github.com/stretchr/testify/require"
"github.com/zzet/gortex/internal/graph"
)
// Empty-origin call edges are resolver-bound usages (the common case for
// languages the resolver binds by name), not name-only text-match fan-out.
// They must survive suppression even when a stronger (LSP-confirmed) edge
// exists for the same target — the rust-analyzer partial-enrichment case
// that otherwise collapsed find_usages from hundreds of sites to a handful.
func TestSuppressRedundantTextMatches_KeepsEmptyOriginWhenResolvedExists(t *testing.T) {
sg := suppressSubGraph(
&graph.Edge{From: "a::caller", To: "b::foo", Kind: graph.EdgeCalls, Origin: graph.OriginLSPResolved},
&graph.Edge{From: "c::c1", To: "b::foo", Kind: graph.EdgeCalls}, // empty origin — resolver-bound
&graph.Edge{From: "d::c2", To: "b::foo", Kind: graph.EdgeCalls}, // empty origin — resolver-bound
&graph.Edge{From: "e::noise", To: "b::foo", Kind: graph.EdgeCalls, Origin: graph.OriginTextMatched},
)
sg.SuppressRedundantTextMatches()
// Only the explicitly text_matched edge is dropped.
require.Equal(t, 3, len(sg.Edges))
require.Equal(t, 1, sg.TextMatchedSuppressed)
for _, e := range sg.Edges {
require.NotEqual(t, graph.OriginTextMatched, e.Origin)
}
}