[Test Coverage] host-iptables branch coverage#4738
Conversation
Cover three branches flagged in the coverage report: - host-iptables-rules.ts:85 — ternary else branch (`''`) when the thrown error from the DOCKER-USER iptables check has no string `stderr` property (plain Error vs ExecaError). - host-iptables-rules.ts:172 — ternary else branch (`DEFAULT_DNS_SERVERS`) when `setupHostIptables` is called with an empty `dnsServers` array. - host-iptables-shared.ts:171 — `if (match)` false branch when a line satisfies `shouldDelete` but does not start with a digit (e.g. an iptables header line like 'Chain FW_WRAPPER (2 references)'). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
✅ Coverage Check PassedOverall Coverage
📁 Per-file Coverage Changes (3 files)
Coverage comparison generated by |
There was a problem hiding this comment.
Pull request overview
Adds a dedicated Jest test file to improve branch coverage in the host iptables logic, specifically exercising previously-uncovered conditional paths in host-iptables-rules and host-iptables-shared via the public APIs.
Changes:
- Adds
src/host-iptables-coverage.test.tsto cover: missing-stderrerror handling, emptydnsServersfallback toDEFAULT_DNS_SERVERS, and thecleanupChain“no leading digit” parsing path. - Uses existing
host-iptables-test-setuphelpers (mockedExeca,execaResult,setupDefaultIptablesMocks, suite reset) to keep tests consistent with existing host-iptables tests.
Show a summary per file
| File | Description |
|---|---|
src/host-iptables-coverage.test.ts |
Adds three targeted tests to cover specific uncovered branches in host iptables setup/cleanup code paths. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 1/1 changed files
- Comments generated: 3
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
The 'addIpv6DnsRules' describe block was missing its closing '});' after the it() block, causing ESLint to report a parse error at EOF. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
GitHub API: ✅ PASS Total: PASS
|
🤖 Smoke Test Results
Overall: FAIL PR: [Test Coverage] host-iptables branch coverage — author:
|
🔥 Smoke Test Results — Auth mode: PAT (COPILOT_GITHUB_TOKEN)PR: [Test Coverage] host-iptables branch coverage —
Overall: PASS
|
Chroot Version Comparison Results
Overall: ❌ Not all tests passed — Python and Node.js versions differ between host and chroot environments.
|
Smoke Test: Copilot BYOK (Direct) Mode✅ GitHub MCP - PRs fetched successfully Status: PASS Author:
|
|
fix(api-proxy): stop double-counting cached tokens in AI credits ✅ Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
network:
allowed:
- defaults
- "registry.npmjs.org"See Network Configuration for more information.
|
Smoke Test: GitHub Actions Services Connectivity
Overall: FAIL
|
Adds
src/host-iptables-coverage.test.tswith three targeted tests that cover branches flagged in the coverage report.What's covered
host-iptables-rules.ts''fallback — thrown error has nostderrstring property (plainnew Error()vsExecaError)checkPermissionsAndSetupChain – no-stderr error objecthost-iptables-rules.tsDEFAULT_DNS_SERVERSfallback —setupHostIptablescalled with[]addIpv6DnsRules – empty dnsServers falls back to DEFAULT_DNS_SERVERShost-iptables-shared.tsif (match)false branch — iptables header line (e.g.Chain FW_WRAPPER (2 references)) matchesshouldDeletebut has no digit prefixcleanupChain – shouldDelete true but line has no leading digitApproach
All tests use the existing
host-iptables-test-setuphelpers (mockedExeca,execaResult,setupDefaultIptablesMocks) and exercise the target functions via their public API (setupHostIptables,cleanupChain). No production code was changed.