Documentation ¶
Overview ¶
Package testutil provides utility functions for tests.
Index ¶
- Constants
- Variables
- func ExtractFixtureArchive(t *testing.T, archivePath string) string
- func RequireMatchingPropertyToBeRedacted(t *testing.T, properties []cdx.Property, name, valueRegex string)
- func RequireMatchingSBOMSnapshot(t *testing.T, snapShooter *cupaloy.Config, bom *cdx.BOM, ...)
- func RequireStdlibComponentToBeRedacted(t *testing.T, bom *cdx.BOM, expectPackages, expectFiles bool)
- func RequireValidSBOM(t *testing.T, bom *cdx.BOM, fileFormat cdx.BOMFileFormat)
- func RequireVolatilePURLQualifiersToBeRedacted(t *testing.T, bom *cdx.BOM)
- func SkipIfShort(t *testing.T)
Constants ¶
const Redacted = "REDACTED"
Redacted marks an intentionally removed field.
Variables ¶
var SilentLogger = zerolog.Nop()
SilentLogger discards all inputs.
Functions ¶
func ExtractFixtureArchive ¶
ExtractFixtureArchive extracts a test fixture's TAR archive to a temporary directory and returns its path.
func RequireMatchingPropertyToBeRedacted ¶
func RequireMatchingPropertyToBeRedacted(t *testing.T, properties []cdx.Property, name, valueRegex string)
RequireMatchingPropertyToBeRedacted ensures that a given property is present and its value matched the provided regex.
If a property matches, its value is then replaced by the string "REDACTED". This is intended to be used for properties that hold dynamic values that are expected to differ from system to system. Only use if absolutely necessary!
func RequireMatchingSBOMSnapshot ¶
func RequireMatchingSBOMSnapshot(t *testing.T, snapShooter *cupaloy.Config, bom *cdx.BOM, fileFormat cdx.BOMFileFormat)
RequireMatchingSBOMSnapshot encodes a BOM and compares it to the snapshot of a test case.
func RequireStdlibComponentToBeRedacted ¶
func RequireStdlibComponentToBeRedacted(t *testing.T, bom *cdx.BOM, expectPackages, expectFiles bool)
RequireStdlibComponentToBeRedacted ensures that a stdlib component is present and redacts its version.
Version will be redacted from packages as well, if applicable. If files are expected, their correlating components will be removed and replaced by an empty slice.
func RequireValidSBOM ¶
RequireValidSBOM encodes the BOM and validates it using the CycloneDX CLI.
func RequireVolatilePURLQualifiersToBeRedacted ¶ added in v1.8.0
func SkipIfShort ¶
SkipIfShort skips the test if `go test` was launched using the -short flag.
Types ¶
This section is empty.