Repository navigation
test(display): cover RenderSummary, RenderStatus and the CVSS/CWE/ref helpers - #328
Conversation
Vulnetix config planManager
0 to create, 1 to update, 0 to delete, 0 unchanged |
0x73746F66
left a comment
There was a problem hiding this comment.
Reuse review: test-only (internal/display). Drives the real RenderSummary/RenderStatus with the package's Context/Terminal types; no duplicated rendering logic. No changes needed.
0x73746F66
left a comment
There was a problem hiding this comment.
Reuse review: no reinvented Vulnetix patterns found. The change stays inside the package it covers, uses stdlib/testify helpers already used by the repo's tests, and adds no new client, auth, config-schema or shared-package duplicate (checked internal/testutils and sibling repos). Rebased onto current main locally: go vet and go test pass for every touched package. The earlier red checks (CodeQL Analyze, Install a release with verified provenance, Lockfile) were GitHub API rate-limit failures, not code failures; this will be re-run on a rebased head before merge.
… helpers Table tests in the package's stdlib style for the renderers and helpers that measured 0%: RenderSummary (every section, missing sections, non-map input, zero severity total), RenderStatus (full, partial, empty, struct and unmarshalable input), extractCVSS priority and first-metric rules, extractCWEs/extractRefs, toInt and toMatchSlice. Closes #296
a0242e5 to
308a9f4
Compare
Vulnetix config planManager
0 to create, 1 to update, 0 to delete, 0 unchanged |
Closes #296
What
New
internal/display/render_summary_test.go, stdlib-only and asserting substrings likerender_advisories_test.go:RenderSummary: a full record (all six section headers, formatted counts, percentages, average EPSS, a skipped non-map CWE entry, a truncated vendor name); a record without sections (header only); non-map input (%vfallback); a zero severity total (rows drawn, no percentage).RenderStatus: full (CLI, OpenAPI spec, API health with sorted extra fields, auth with org id); partial (no spec, no health, no org id); empty map (header only); a struct through its JSON tags; a value with no JSON form falls back to%v.extractCVSS: each of v4.0/v3.1/v3.0/v2.0 sets its version string; v4 wins inside one metric; the first metric carrying any cvss key wins; missing metrics, non-list metrics and metrics without a cvss key leave everything zero; values already set are kept.extractCWEs/extractRefs: extraction skipping malformed entries; empty results when the containers are missing.toInt(int, int64, float64, other -> 0) andtoMatchSlice([]anysubset,[]map[string]anypassthrough, other -> nil, empty -> empty).Test-only. Package coverage 18.6% -> 24.3%.
Verified
go test -cover ./internal/display/passes;gofmtclean.