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
33 lines
1.2 KiB
Go
33 lines
1.2 KiB
Go
package graph
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
// TestCaveatForZeroEdge_NotFoundMessage asserts a queried id that is not in
|
|
// the graph (e.g. mistyped or missing its repo prefix) gets a caveat that
|
|
// points at the id — while still carrying the untrustworthy class so a
|
|
// safety gate trips — and that an existing zero-edge symbol keeps the
|
|
// extraction-gap message.
|
|
func TestCaveatForZeroEdge_NotFoundMessage(t *testing.T) {
|
|
g := New()
|
|
g.AddNode(&Node{ID: "repo/a.go::Lonely", Kind: KindFunction, Name: "Lonely"}) // exists, no edges
|
|
|
|
notFound := CaveatForZeroEdge(g, "a.go::Missing")
|
|
if notFound == nil || notFound.Class != ZeroEdgePossibleExtractionGap {
|
|
t.Fatalf("a not-found id must still carry the untrustworthy class; got %+v", notFound)
|
|
}
|
|
if !strings.Contains(notFound.Message, "repo prefix") {
|
|
t.Errorf("not-found message should point at the id/prefix; got %q", notFound.Message)
|
|
}
|
|
|
|
existing := CaveatForZeroEdge(g, "repo/a.go::Lonely")
|
|
if existing == nil {
|
|
t.Fatal("an existing zero-edge symbol should still carry a caveat")
|
|
}
|
|
if strings.Contains(existing.Message, "repo prefix") {
|
|
t.Errorf("an existing zero-edge symbol should get the extraction-gap message, not the not-found one; got %q", existing.Message)
|
|
}
|
|
}
|