Skip to content

test(display): cover RenderSummary, RenderStatus and the CVSS/CWE/ref helpers - #328

Merged
0x73746F66 merged 1 commit into
mainfrom
fix/296-display-render-tests
Nov 13, 2026
Merged

0x73746F66 merged 1 commit into
mainfrom
fix/296-display-render-tests

Conversation

@0x73746F66

Copy link
Copy Markdown
Member

Closes #296

What

New internal/display/render_summary_test.go, stdlib-only and asserting substrings like render_advisories_test.go:

  1. 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 (%v fallback); a zero severity total (rows drawn, no percentage).
  2. 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.
  3. 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.
  4. extractCWEs / extractRefs: extraction skipping malformed entries; empty results when the containers are missing.
  5. toInt (int, int64, float64, other -> 0) and toMatchSlice ([]any subset, []map[string]any passthrough, other -> nil, empty -> empty).

Test-only. Package coverage 18.6% -> 24.3%.

Verified

go test -cover ./internal/display/ passes; gofmt clean.

@github-actions

Copy link
Copy Markdown
Contributor

Vulnetix config plan

Manager gitops:vulnetix/cli, prune off, plan hash a8bd984f1753c68b180298051dd9e2524ab644d2ebe9e4c7c811ff4126753b5f

Object Action Changes
~ QualityGate/default update (adopt) severity: null -> "high"

0 to create, 1 to update, 0 to delete, 0 unchanged

@0x73746F66 0x73746F66 left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 0x73746F66 left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
@0x73746F66
0x73746F66 force-pushed the fix/296-display-render-tests branch from a0242e5 to 308a9f4 Compare November 13, 2026 11:18
@github-actions

Copy link
Copy Markdown
Contributor

Vulnetix config plan

Manager gitops:vulnetix/cli, prune off, plan hash a8bd984f1753c68b180298051dd9e2524ab644d2ebe9e4c7c811ff4126753b5f

Object Action Changes
~ QualityGate/default update (adopt) severity: null -> "high"

0 to create, 1 to update, 0 to delete, 0 unchanged

@0x73746F66
0x73746F66 merged commit 3022433 into main Nov 13, 2026
29 of 32 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cover internal/display RenderSummary/RenderStatus and the extractCVSS/CWE/ref helpers

1 participant