Skip to content

test: cover pkg/deploy against Substrate (4.1% -> 75.5%) - #125

Merged
scttfrdmn merged 1 commit into
mainfrom
test/1-deploy-coverage
Aug 19, 2026
Merged

test: cover pkg/deploy against Substrate (4.1% -> 75.5%)#125
scttfrdmn merged 1 commit into
mainfrom
test/1-deploy-coverage

Conversation

@scttfrdmn

Copy link
Copy Markdown
Contributor

Summary

  • Adds a Substrate-backed test suite for pkg/deploy (deploy_substrate_test.go), covering Deploy, Teardown, StackOutputs, ensureBucket, and uploadArtifact — previously untested; only the package's 4 pure helper functions (LambdaArtifactURL, DefaultBucketName, LambdaObjectKey, failedCreateStates) had coverage.
  • pkg/deploy coverage: 4.1% → 75.5%. Aggregate repo coverage: 51.2% → 54.4% (measured on current main; note the issue's original 20.9% figure is stale — a lot of test debt has already been paid down elsewhere since Raise test coverage — only pkg/watcher tested, aggregate 20.9% #1 was filed).
  • No behavior change — test-only.

Progresses #1.

Why this package, and why not a blanket coverage push

Per the task's own framing, I looked at where aggregate coverage sits today rather than trusting the issue's number, and picked the single weakest non-trivial package instead of chasing an aggregate percentage target:

Package Coverage (before this PR)
pkg/deploy 4.1%
cmd/ 18.8%
pkg/watcher 69.8%
pkg/snipe 78.1%
pkg/runtimeiam 87.5%
pkg/failure, pkg/awscfg 100%

pkg/deploy was the clear outlier and the best-scoped target: Deployer already takes an injectable aws.Config (deploy.New(cfg)), so it was straightforward to point at pkg/testutil.SubstrateServer — the same substrate-backed pattern pkg/watcher's own tests already use — with no source changes needed, just missing tests. cmd/ is comparatively lower-value to chase: most of its 0%-covered functions are run* cobra handlers that are thin CLI-argument-to-library-call wiring, better suited to a follow-up that specifically covers flag parsing/wiring rather than folded into this PR.

Not attempted here: the createOrUpdate failed-create-state (ROLLBACK_COMPLETE etc.) delete-and-recreate branch — forcing a stack into that state would need Substrate's fault-injection wired up, which felt like more machinery than this PR's scope justified. Left as a known gap rather than adding something speculative/brittle.

Verification

  • go build ./..., go vet ./..., go test ./... clean from repo root.
  • go build ./..., go vet ./..., go test ./... clean from lambda/capacity-poller (untouched, confirmed still green).
  • golangci-lint run ./pkg/deploy/... — 0 issues.
  • All 9 new tests pass; no live AWS calls (Substrate emulator only).

Test plan

  • CI green

@codecov

codecov Bot commented Aug 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

pkg/deploy (lagotto's `deploy`/`teardown` stack manager) was the least-
covered non-trivial package in the repo (#1): only its 4 pure helper
functions (LambdaArtifactURL, DefaultBucketName, LambdaObjectKey,
failedCreateStates) had tests. Deploy/Teardown/StackOutputs/ensureBucket/
uploadArtifact — the actual AWS-calling code — had none, despite Deployer
already taking an injectable aws.Config (deploy.New(cfg)), which is exactly
what a Substrate-backed test needs.

Adds pkg/deploy/deploy_substrate_test.go using the same
pkg/testutil.SubstrateServer + fake-httpGet pattern pkg/watcher's own
substrate tests already use, covering:
  - Deploy end-to-end (bucket create + artifact upload + CreateStack,
    verified against the real SAM-transformed stack's outputs)
  - Redeploy (the UpdateStack branch of createOrUpdate)
  - Teardown (DeleteStack + wait, then stackState confirms it's gone)
  - StackOutputs for both a deployed and an undeployed stack
  - ensureBucket's idempotent-already-exists path
  - uploadArtifact's httpGet-error and non-200-status error paths

pkg/deploy: 4.1% -> 75.5% coverage. Aggregate repo coverage: 51.2% -> 54.4%.
Not attempted: the failed-create-state (ROLLBACK_COMPLETE etc.)
delete-and-recreate branch in createOrUpdate, which would need Substrate's
fault-injection to force a stack into that state — left uncovered rather
than adding a speculative/brittle test for it.

Progresses #1 (broad coverage-debt issue; scoped here to the single
weakest package rather than a blanket aggregate-percentage chase).
@scttfrdmn
scttfrdmn force-pushed the test/1-deploy-coverage branch from 5837fbf to adf2106 Compare August 19, 2026 02:40
@scttfrdmn
scttfrdmn merged commit 204b9a3 into main Aug 19, 2026
5 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