[Test Coverage] Branch coverage gaps: signal-handler, preflight, compose-generator, compose-network#6085
Conversation
Cover previously-uncovered branches identified in the coverage report: - commands/signal-handler.ts line 46: SIGTERM with keepContainers=true - commands/preflight.ts lines 51,73,82,217: String(error) for non-Error - compose-generator.ts line 29: buildLocal + missing containers dir - compose-generator.ts line 84: GITHUB_WORKSPACE unset fallback - compose-generator.ts line 152: service without environment key - compose-network.ts line 37: squidService.networks pre-existing Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
✅ Coverage Check PassedOverall Coverage
📁 Per-file Coverage Changes (2 files)
Coverage comparison generated by |
There was a problem hiding this comment.
Pull request overview
Adds targeted Jest tests to close branch-coverage gaps in several security-critical paths (signal handling shutdown, preflight error handling, and Docker compose generation/network wiring).
Changes:
- Add a focused multi-target branch-coverage test suite covering signal-handler, preflight non-
Errorcatch branches, compose-generator fallbacks, secret redaction, and compose-network merge behavior. - Add a dedicated test file to cover
generateDockerCompose’s--build-local“missing containers dir” throw path with a module-levelfsmock.
Show a summary per file
| File | Description |
|---|---|
| src/coverage-branch-gaps-3.test.ts | Adds targeted branch-coverage tests for signal handling, preflight error logging branches, compose generation fallbacks/redaction, and compose network merging. |
| src/compose-generator-buildlocal.test.ts | Adds tests for the buildLocal=true guard path when the containers/ directory is missing, using a dedicated fs mock setup. |
Review details
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 2/2 changed files
- Comments generated: 6
- Review effort level: Low
| * Targets: | ||
| * src/commands/signal-handler.ts line 46: SIGTERM + keepContainers=true (false branch of &&) | ||
| * src/commands/preflight.ts lines 51,73,82,217: String(error) path for non-Error throws | ||
| * src/compose-generator.ts line 29: buildLocal + containers dir missing (throw branch) |
| it('uses non-Error value directly when loadAndMergeDomains throws a non-Error (line 82)', () => { | ||
| mockedRules.loadAndMergeDomains.mockImplementation(() => { | ||
| // eslint-disable-next-line @typescript-eslint/only-throw-error | ||
| throw { message: 'yaml object error' }; | ||
| }); | ||
|
|
||
| expect(() => parseDomainOptions({ rulesetFile: ['/bad.yml'] })).toThrow('process.exit called'); | ||
| expect(mockedLogger.error).toHaveBeenCalledWith( | ||
| expect.stringContaining('Failed to load ruleset file') | ||
| ); | ||
| }); |
| // squid must have both awf-net (original) and awf-ext (added) | ||
| const squidNetworks = squidService.networks as Record<string, unknown>; | ||
| expect(squidNetworks).toHaveProperty('awf-net'); | ||
| expect(squidNetworks).toHaveProperty('awf-ext'); |
|
@copilot Fix the code for all comments in this review thread. When a review comment includes a suggested change, apply the suggestion exactly. Do not make changes beyond what is described in the linked review thread. |
All 6 review comments addressed in commit c667fe8:
|
|
✅ Copilot review passed with no inline comments. @github-actions[bot] Add the |
|
🔑 Smoke Copilot PAT PAT auth validated. All systems operational. ✅ |
|
✅ Build Test Suite completed successfully! |
|
🔌 Smoke Services — All services reachable! ✅ |
|
✅ Smoke Claude passed |
|
📡 Smoke OTel Tracing completed. All tracing scenarios validated. ✅ |
|
❌ Smoke Copilot BYOK AOAI (api-key) reports failed. AOAI BYOK (api-key) mode investigation needed... |
|
🚀 Security Guard has started processing this pull request |
|
✅ Smoke Copilot BYOK completed. Copilot BYOK mode operational. 🔓 |
|
❌ Smoke Copilot BYOK AOAI (Entra) reports failed. AOAI BYOK (Entra) mode investigation needed... |
|
✅ Contribution Check completed successfully! PR #6085 follows the applicable CONTRIBUTING.md guidelines: changes are organized under src/, targeted tests are included for the coverage gaps, the PR description clearly explains the scope and reports test results, and no documentation update is needed for test-only changes. |
|
✅ Smoke Gemini completed. All facets verified. 💎 Smoke test failed. GitHub MCP tools missing and connectivity to GitHub.com failed. |
|
Chroot tests passed! Smoke Chroot - All security and functionality tests succeeded. |
|
📰 VERDICT: Smoke Copilot has concluded. All systems operational. This is a developing story. 🎤 |
Smoke Test: PAT Auth — PASS ✅
Overall: PASS CC Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
network:
allowed:
- defaults
- "awmgmcpg"See Network Configuration for more information.
|
Smoke Test: Services Connectivity
Result: FAIL — Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
network:
allowed:
- defaults
- "awmgmcpg"See Network Configuration for more information.
|
🔬 Smoke Test Results
Overall: PASS (core connectivity confirmed) Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
network:
allowed:
- defaults
- "awmgmcpg"See Network Configuration for more information.
|
Smoke Test: Copilot BYOK (Direct)
Running in direct BYOK mode ( Overall: PASS Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
network:
allowed:
- defaults
- "awmgmcpg"See Network Configuration for more information.
|
Smoke Test: API Proxy OpenTelemetry Tracing
All scenarios pass. Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
network:
allowed:
- defaults
- "awmgmcpg"See Network Configuration for more information.
|
Smoke Test: Claude Engine Validation
Overall Result: PASS ✅ Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
network:
allowed:
- defaults
- "awmgmcpg"See Network Configuration for more information.
|
Smoke Test Results
Overall status: PASS Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
network:
allowed:
- defaults
- "localhost"See Network Configuration for more information.
|
🏗️ Build Test Suite Results
Overall: 8/8 ecosystems passed — ✅ PASS Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
network:
allowed:
- defaults
- "awmgmcpg"See Network Configuration for more information.
|
Chroot Version Comparison Results
Not all tests passed — Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
network:
allowed:
- defaults
- "awmgmcpg"See Network Configuration for more information.
|
Summary
Closes branch-coverage gaps identified in the coverage report for security-critical code paths.
Files Added
src/coverage-branch-gaps-3.test.tsCovers uncovered branches across multiple files:
commands/signal-handler.tsline 46: SIGTERM withkeepContainers=true(false branch ofgetContainersStarted() && !keepContainers)commands/preflight.tslines 51, 73, 82, 217:String(error)path when non-Errorobjects are thrown in config loading, domain file reading, ruleset loading, and blocked-domain validationcompose-generator.tsline 84:process.env.GITHUB_WORKSPACEunset →process.cwd()fallback branchcompose-generator.tsline 152:redactDockerComposeSecretswith a service that has noenvironmentkey (falsy branch of&&)compose-network.tsline 37:squidService.networksalready populated (truthy branch of|| {})src/compose-generator-buildlocal.test.tsCovers the throw path in
generateDockerComposewhenbuildLocal=truebut thecontainers/directory is absent (line 29). Uses a module-leveljest.mock('fs')to makeexistsSyncconfigurable — kept in a separate file to avoid conflicts with tests that need realfs.Branches Covered
commands/signal-handler.tskeepContainers=truecommands/preflight.tsString(error)in config load catchcommands/preflight.tscommands/preflight.tscommands/preflight.tscompose-generator.tsbuildLocal+ missing containers dircompose-generator.tsGITHUB_WORKSPACEunset fallbackcompose-generator.tsenvironmentkeycompose-network.tssquidService.networkspre-existingTest Results
All 12 new tests pass locally.
Warning
Firewall blocked 1 domain
The following domain was blocked by the firewall during workflow execution:
awmgmcpgSee Network Configuration for more information.