test(docker): cover failedBootSentinel branches - #1012
Merged
Conversation
add direct unit tests; no behavioral change
✅ Deploy Preview for images-devsy-sh ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for devsydev ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 5 |
| Duplication | 0 |
AI Reviewer: run a review on demand. To trigger the first review automatically, go to your organization or repository integration settings. AI can make mistakes. Always validate suggestions.
TIP This summary will be updated as you push new changes.
Lift the repeated container status string literals (dead, removing, exited, created, paused, restarting) into constants so goconst stops flagging them. Lint fix only; no behavior change. This commit was created by an AI agent (OpenHands) on behalf of the user.
|
Tick the box to add this pull request to the merge queue (same as
|
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.
Package reviewed
pkg/docker— the Docker helper/boot-state classification logic inhelper.go.Issue found
failedBootSentinel(status, graceElapsed)(pkg/docker/helper.go:626) is a pureclassifier that maps a container status + grace-window state to one of
ErrContainerTerminal,ErrContainerExited, ornil. It had no direct unittests. The only coverage came indirectly through
TestWaitContainerRunning_*in
helper_test.go, which is:exited-after-grace path only fires after a ~2s gracewindow elapses inside
WaitContainerRunning, making the suite slow (2s) andbrittle.
removing,created, grace-not-elapsed,and unknown-status paths were never explicitly checked. A regression that, for
example, swapped the terminal sentinel for
"removing"vs"exited"(orflipped the grace logic) would not be caught.
Change
Add
pkg/docker/boot_state_test.go(new file, no edits to existing files):TestFailedBootSentinel: table-driven test covering every(status, graceElapsed)branch explicitly —
dead,removing(terminal regardless of grace),exited/createdbefore/after grace, plus non-terminal/unknown statuses (paused,restarting, empty).TestFailedBootSentinel_TerminalNotConfusedWithExited: guards against terminalstates being misreported as
ErrContainerExitedand vice-versa.Tests run in ~0.01s with no timing dependency. No behavioral change; tests only.
Verification performed
task cli:format— clean (gofmt/gci/gofumpt via golangci-lint fmt).task cli:lint:ci— 0 new issues (golangci-lint --new-from-patch).task cli:test—pkg/dockerpasses (ok ... 2.081s); the only failures are theknown pre-existing
pkg/gitTestRepoClone*suite, which this change does nottouch (confirmed unchanged per the task's known-failure allowance).
go test ./pkg/docker/ -run TestFailedBootSentinel -v→ all subtests PASS.
Expected effect
Makes the boot-state classification contract explicit and fast, so a regression
in
failedBootSentinelis caught immediately rather than only through a slow,timing-dependent integration path.
This PR was created by an AI agent as part of an automated daily package review job.