test(handlers): expand deploy + stack handler coverage#153
Open
mastermanas805 wants to merge 3 commits into
Open
test(handlers): expand deploy + stack handler coverage#153mastermanas805 wants to merge 3 commits into
mastermanas805 wants to merge 3 commits into
Conversation
Add ~70 targeted tests for the deploy.go and stack.go handlers covering multipart tarball parsing, tier-cap 402 walls, env-vars merge/key-validation, vault-ref resolution, needs:-resource resolution, promote approval flow (consumeApprovedPromote), dev-env promote execution, two-step deletion (confirm/cancel), and the async runDeploy/runStackDeploy/runStackRedeploy goroutine success+failure branches via injected compute/stack-provider doubles and DB-fault paths. Adds a test-only SetStackProvider setter (mirrors SetComputeProvider) and export_test.go wrappers so external tests can exercise unexported helpers (truncateForAudit, resourceEnvKey, parseResourceToken, rewriteToInternalURL, runDeploy, captureAutopsy) without an import cycle through testhelpers. deploy.go ~71% -> ~86%, stack.go ~62% -> ~77%. Remaining uncovered paths are k8s-constructor init and deep defensive error tails not reachable without a live cluster. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Add gap-filling tests for deploy.go and stack.go error and edge branches: manifest/tarball/token/env validation on /stacks/new, promote invalid-body/env-mismatch/no-services/missing-image-ref/create-target paths, copyVaultRefsForPromote no-op + skip-existing + per-key copy, stack Redeploy/UpdateEnv merge+delete+cross-team, and closed-DB 503 arms for stack UpdateEnv/Promote/Family. Lifts deploy.go ~82->83% and stack.go ~72->80%. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Add a real-DB test that pre-seeds a target stack in the same family so Promote takes the updated_existing path — covering both the existing-service image_ref update and the missing-service create branches. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
deploy.goandstack.gohandlers: multipart tarball parsing, tier-cap 402 walls, env-vars merge + POSIX key validation (incl. empty-string deletes + 64KiB cap), vault-ref resolution,needs:-resource resolution (resolve/inject/cross-team/deleted), promote approval flow (consumeApprovedPromote— all branches), dev-env promote execution, two-step email-confirmed deletion (confirm/cancel success + cross-team + 404), and the asyncrunDeploy/runStackDeploy/runStackRedeploygoroutine success+failure branches via injected compute/stack-provider doubles and closed-DB fault paths.SetStackProvidersetter onStackHandler(mirrors the existingSetComputeProvideronDeployHandler) plusexport_test.gowrappers so externalhandlers_testtests can exercise unexported helpers without an import cycle throughtesthelpers.Coverage
deploy.go: ~71% → ~86%stack.go: ~62% → ~77%rand.Readfailure, and deep best-effort defensive error tails (audit goroutines, teardown-failure warns). The 95% target was not fully reached onstack.go; the remaining gap is largely structurally unreachable in unit tests.Test plan
go test ./internal/handlers -run '<new tests>' -count=1 -p 1go build ./...+go vet ./internal/handlersclean🤖 Generated with Claude Code