Skip to content

Add provider→scanner→output integration tests and per-package coverage floors#26

Merged
stxkxs merged 1 commit into
mainfrom
uplift-integration-ci-floors
Jun 5, 2026
Merged

Add provider→scanner→output integration tests and per-package coverage floors#26
stxkxs merged 1 commit into
mainfrom
uplift-integration-ci-floors

Conversation

@stxkxs

@stxkxs stxkxs commented Jun 5, 2026

Copy link
Copy Markdown
Member

The final target of the uplift: end-to-end tests across the layers, a per-package coverage gate, and a latent bug the new tests surfaced.

Integration tests

internal/integration runs the provider → scanner → output path with a fixture provider registered through the real registry (providers.NewRegistry/Capable), resolved by capability, run through each domain scanner, and rendered to both JSON and table. Six domains (orphans, storage, network, certs, tags, secrets) assert multiple rendered fields each, plus a case proving the scanner's MinSeverity actually drops a below-threshold finding, plus the no-provider error path.

A command's RunE resolves via providers.Resolve (→ Default()), which is AWS-backed and intentionally has no test-injection seam — so the cobra shell (flag→ScanOptions, output-format switch, gate/exit-code) is covered by package cmd's unit tests, not here. (Honest framing, per review.)

Remediate bugfix (found by the new tests)

The cmd helper tests exposed that remediate's bare-array fallback was unreachable: a bare JSON array fails the envelope unmarshal and errored before the fallback ran, so cloudgov remediate --from <hand-crafted-array.json> was silently broken. The three unmarshalers now try envelope → bare array → useful error, with tests for envelope, bare-array, invalid-JSON, and empty-envelope.

Per-package coverage floors

.coverage-floors (one floor per package, a few points below current, ratcheting) enforced by scripts/coverage.sh in ci.yml. Fails on three conditions: a package below its floor, a floored package with no coverage line (stale/typo'd name), and a tested package with no floor (ungated new code). Replaces the single 50% total floor. golangci-lint + coverage profiling were already in CI.

Verification

Local: full suite green, all 25 floors met (total ~61%), shellcheck + lint clean; both new floor-guard paths verified to fail correctly. An adversarial review workflow (3 dimensions → verify) raised 12 findings — bugfix + floor logic verified correct; the rest (seam labeling honesty, multi-field assertions, filter discrimination, the two floor guards, bugfix edge-case tests) are all addressed in this PR.

Completes backlog section 7 — the cloudgov uplift.

…e floors

The final piece of the uplift: end-to-end tests across the layers, a
per-package coverage gate so no package can silently regress, and a latent
bug the new tests surfaced.

──────────────────────── integration tests ────────────────────────

internal/integration runs the provider → scanner → output path with a
fixture provider registered through the real provider registry
(providers.NewRegistry / Capable), resolved by capability, run through each
domain scanner, and rendered to both JSON and table. Six domains (orphans,
storage, network, certs, tags, secrets) assert multiple rendered fields each,
plus a case that proves the scanner's MinSeverity actually drops a
below-threshold finding, and the no-provider error path.

A command's RunE resolves providers via providers.Resolve (→ Default()),
which is AWS-backed and intentionally has no test-injection seam, so the
cobra shell (flag→ScanOptions, the output-format switch, gate/exit-code) is
covered by package cmd's unit tests rather than here.

──────────────────────── remediate bugfix ─────────────────────────

Adding cmd helper tests (cmd/remediate_test.go) exposed that remediate's
bare-array fallback was unreachable: a bare JSON array fails the envelope
unmarshal and returned an error before the fallback ran, so
`cloudgov remediate --from <hand-crafted-array.json>` was silently broken.
The three unmarshalers now try the envelope, then the bare array, then report
a useful error — with tests for envelope, bare-array, invalid-JSON, and the
empty-envelope path.

──────────────────────── per-package floors ───────────────────────

.coverage-floors sets a floor per package (a few points below current, to
ratchet up as coverage lands). scripts/coverage.sh enforces them in ci.yml
and fails on three conditions: a package below its floor, a floored package
that produced no coverage line (stale/typo'd name), and a package that
reports coverage but has no floor (so new tested code can't land ungated).
This replaces the single 50% total floor. golangci-lint and coverage
profiling were already wired into CI.
@stxkxs stxkxs merged commit a96c530 into main Jun 5, 2026
4 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.

1 participant