Skip to content

[Test Coverage] container-startup-diagnostics.ts coverage#6493

Draft
github-actions[bot] wants to merge 1 commit into
mainfrom
test-coverage/container-startup-diagnostics-coverage-c99b95e83d0ec7d8
Draft

[Test Coverage] container-startup-diagnostics.ts coverage#6493
github-actions[bot] wants to merge 1 commit into
mainfrom
test-coverage/container-startup-diagnostics-coverage-c99b95e83d0ec7d8

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

Improves test coverage for src/container-startup-diagnostics.ts from ~65% to ~98%.

What's covered

New tests in src/container-startup-diagnostics-coverage.test.ts:

didContainerFailStartup

  • docker inspect exits non-zero → returns false
  • docker inspect throws → returns false
  • Inspect output shows exited status → true
  • Inspect output shows unhealthy health → true

logContainerLogsToStderr

  • docker logs exits non-zero → no output logged
  • docker logs succeeds with empty output → no output logged
  • docker logs throws → handled gracefully

detectDnsResolutionFailure

  • docker logs exits non-zero → null
  • EAI_AGAIN pattern in stdout → hostname returned
  • ENOTFOUND pattern in stderr → hostname returned
  • No DNS pattern → null
  • Throws → null

reportBlockedDomains

  • Non-standard port on allowlisted domain → portIssues classification + fix suggestion (lines 161-162, 181)
  • Wildcard *.domain.com matching with non-standard port → port issue (exercises lines 139-141)
  • Protocol mismatch path
  • Else branch (allowed domain, standard port)

handleHealthcheckError

  • No denials found → rethrows original error
  • Error message doesn't match → rethrows without calling checkSquidLogs
  • Denials found → user-friendly domain error

Generated by Test Coverage Improver · 105.5 AIC · ⊞ 6.2K ·

Add targeted tests covering previously uncovered branches:
- portIssues branch (non-standard port on allowlisted domain) + fix suggestion
- wildcard pattern matching with non-standard port (*.domain matching)
- Additional didContainerFailStartup inspect paths
- detectDnsResolutionFailure all branches (non-zero exit, EAI_AGAIN/ENOTFOUND, throws)
- logContainerLogsToStderr non-zero exit and throws paths
- handleHealthcheckError no-denials rethrow path

Coverage improves from ~65% to ~98% on container-startup-diagnostics.ts.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.

0 participants