Documentation
¶
Overview ¶
Package testkit provides test helpers for component modules and external plugins: fuzz-target invariants, Go binary builders for fake tools, and lockfile position assertions.
Index ¶
- Constants
- func BuildGoBinary(t testing.TB, outputPath, source string) error
- func BuildGoBinaryFromSource(outputPath, source string) error
- func MustDependencyCoords(t testing.TB, coords sdk.Coordinates) *sdk.DependencyNode
- func MustDependencyNode(t testing.TB, rawPURL string) *sdk.DependencyNode
- func MustModuleNode(t testing.TB, manifestPath string, coords sdk.Coordinates) *sdk.ModuleNode
- func RequireFuzzGraphValid(t *testing.T, graph *sdk.Graph)
- func RequireLockfilePositions(t *testing.T, detector sdk.Detector, fixtureDir string, ...)
Constants ¶
const MaxFuzzInputSize = 1 << 20
MaxFuzzInputSize is the shared upper bound for parser fuzz payloads.
Variables ¶
This section is empty.
Functions ¶
func BuildGoBinary ¶
BuildGoBinary writes source to a temporary file and builds it into outputPath.
func BuildGoBinaryFromSource ¶
BuildGoBinaryFromSource is BuildGoBinary for callers without a testing handle — package TestMain functions that build shared fake binaries once. It manages its own temporary source directory.
func MustDependencyCoords ¶ added in v0.6.0
func MustDependencyCoords(t testing.TB, coords sdk.Coordinates) *sdk.DependencyNode
MustDependencyCoords constructs a dependency node from coordinates and fails the test when the constructor rejects them. Test-fixture counterpart of sdk.NewDependencyNode.
func MustDependencyNode ¶ added in v0.6.0
func MustDependencyNode(t testing.TB, rawPURL string) *sdk.DependencyNode
MustDependencyNode constructs a dependency node from a raw package URL and fails the test when the constructor rejects it. Test-fixture counterpart of sdk.NewDependencyNodeFromPURL for detector, matcher, and plugin tests.
func MustModuleNode ¶ added in v0.6.0
func MustModuleNode(t testing.TB, manifestPath string, coords sdk.Coordinates) *sdk.ModuleNode
MustModuleNode constructs a module node and fails the test when the constructor rejects the path or coordinates. Test-fixture counterpart of sdk.NewModuleNode.
func RequireFuzzGraphValid ¶
RequireFuzzGraphValid verifies the minimum invariants of a successfully parsed dependency graph.
func RequireLockfilePositions ¶
func RequireLockfilePositions(t *testing.T, detector sdk.Detector, fixtureDir string, wantPositionKeys []string)
RequireLockfilePositions resolves fixtureDir with the given detector and asserts that every named package in the resolved graph carries at least one non-empty source position (a location whose Position names a file and a 1-based line). It is the per-detector replacement for the Bomly CLI's cross-detector position test: each detector module keeps its own lockfile fixture and asserts its own position extraction with one call.
wantPositionKeys entries are graph node IDs — canonical package URLs such as "pkg:npm/left-pad@1.3.0" (ADR-0041). A missing node or a node without a position fails the test with the offending key.
Types ¶
This section is empty.