Skip to content

test(docker): cover failedBootSentinel branches - #1012

Merged
skevetter merged 3 commits into
mainfrom
pkg-container/failed-boot-sentinel-tests
Aug 18, 2026
Merged

test(docker): cover failedBootSentinel branches#1012
skevetter merged 3 commits into
mainfrom
pkg-container/failed-boot-sentinel-tests

Conversation

@devsy-app

@devsy-app devsy-app Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Package reviewed

pkg/docker — the Docker helper/boot-state classification logic in helper.go.

Issue found

failedBootSentinel(status, graceElapsed) (pkg/docker/helper.go:626) is a pure
classifier that maps a container status + grace-window state to one of
ErrContainerTerminal, ErrContainerExited, or nil. It had no direct unit
tests
. The only coverage came indirectly through TestWaitContainerRunning_*
in helper_test.go, which is:

  • Timing-dependent: the exited-after-grace path only fires after a ~2s grace
    window elapses inside WaitContainerRunning, making the suite slow (2s) and
    brittle.
  • Leaves branches unasserted: the 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" (or
    flipped 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/
    created before/after grace, plus non-terminal/unknown statuses (paused,
    restarting, empty).
  • TestFailedBootSentinel_TerminalNotConfusedWithExited: guards against terminal
    states being misreported as ErrContainerExited and 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:ci0 new issues (golangci-lint --new-from-patch).
  • task cli:testpkg/docker passes (ok ... 2.081s); the only failures are the
    known pre-existing pkg/git TestRepoClone* suite, which this change does not
    touch (confirmed unchanged per the task's known-failure allowance).
  • New tests pass directly: 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 failedBootSentinel is 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.

add direct unit tests; no behavioral change
@netlify

netlify Bot commented Aug 12, 2026

Copy link
Copy Markdown

Deploy Preview for images-devsy-sh ready!

Name Link
🔨 Latest commit fd34f85
🔍 Latest deploy log https://app.netlify.com/projects/images-devsy-sh/deploys/6a83db51ea1e2300084d2bbf
😎 Deploy Preview https://deploy-preview-1012--images-devsy-sh.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify

netlify Bot commented Aug 12, 2026

Copy link
Copy Markdown

Deploy Preview for devsydev ready!

Name Link
🔨 Latest commit fd34f85
🔍 Latest deploy log https://app.netlify.com/projects/devsydev/deploys/6a83db51ed26890008704562
😎 Deploy Preview https://deploy-preview-1012--devsydev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 5 complexity · 0 duplication

Metric Results
Complexity 5
Duplication 0

View in Codacy

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.

Run reviewer

TIP This summary will be updated as you push new changes.

devsy-app Bot and others added 2 commits August 13, 2026 16:39
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.
@mergify

mergify Bot commented Aug 18, 2026

Copy link
Copy Markdown

Tick the box to add this pull request to the merge queue (same as @mergifyio queue).

  • Queue this pull request

@skevetter
skevetter merged commit beb2f70 into main Aug 18, 2026
135 of 137 checks passed
@skevetter
skevetter deleted the pkg-container/failed-boot-sentinel-tests branch August 18, 2026 13:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant