[Test Coverage] Add test coverage for build-config and predownload commands#3455
Conversation
- Add src/commands/build-config.test.ts: covers buildConfig() function which was 0% functions / 0% branches. Tests cover: - blockedDomains / additionalEnv / excludeEnv conditional handling - tty and diagnosticLogs default-false fallback - API key resolution from process.env (openai, anthropic, gemini, copilot) - githubToken GITHUB_TOKEN vs GH_TOKEN precedence - auditDir / sessionStateDir env var fallbacks - API target env var fallbacks (openai, anthropic, gemini) - Pass-through fields (volumeMounts, upstreamProxy, dnsServers, etc.) - Extend src/commands/predownload.test.ts: cover validateImageReference branches and the 'act' preset image path: - act preset pulls agent-act image - custom image reference used as-is - image starting with '-' throws validation error - image with whitespace throws validation error Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This comment has been minimized.
This comment has been minimized.
✅ Coverage Check PassedOverall Coverage
📁 Per-file Coverage Changes (3 files)
Coverage comparison generated by |
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.
There was a problem hiding this comment.
Pull request overview
Adds unit tests to improve coverage for configuration assembly (buildConfig) and Docker image predownload behavior, increasing confidence in env-driven config and image reference validation.
Changes:
- Added
src/commands/build-config.test.tsto cover env var resolution, option fallbacks, and pass-through fields inbuildConfig(). - Extended
src/commands/predownload.test.tsto cover theactpreset image selection, custom image refs, and invalid image reference rejection paths.
Show a summary per file
| File | Description |
|---|---|
| src/commands/build-config.test.ts | New unit tests for buildConfig() covering env var resolution, fallbacks, and passthrough behavior. |
| src/commands/predownload.test.ts | Adds branch-coverage tests for agent image selection presets and invalid custom image reference handling. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 2/2 changed files
- Comments generated: 1
| beforeEach(() => { | ||
| jest.clearAllMocks(); | ||
| mockResolveCopilotApiKey.mockReturnValue(undefined); | ||
| // Clear env vars that affect the output | ||
| delete process.env.OPENAI_API_KEY; | ||
| delete process.env.ANTHROPIC_API_KEY; | ||
| delete process.env.COPILOT_GITHUB_TOKEN; | ||
| delete process.env.GEMINI_API_KEY; | ||
| delete process.env.GITHUB_TOKEN; | ||
| delete process.env.GH_TOKEN; | ||
| delete process.env.AWF_AUDIT_DIR; | ||
| delete process.env.AWF_SESSION_STATE_DIR; | ||
| }); |
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.
|
@copilot address review feedback |
Fixed in commit The |
🔥 Smoke Test Results
Overall: PASS PR: [Test Coverage] Add test coverage for build-config and predownload commands
|
Smoke Test: Copilot BYOK Offline Mode
Running in BYOK offline mode ( PR by Overall: PASS (core BYOK inference path confirmed ✅)
|
|
✅ GitHub API - 2 PR entries confirmed Result: PASS
|
|
Merged PRs: Align log discovery with canonical Squid container constant; Refactor api-proxy startup to adapter-only validation/model discovery paths 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 Results
Overall status: FAIL 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.
|
Chroot Smoke Test Results
Overall: ❌ Not all tests passed — Python and Node.js versions differ between host and chroot.
|
🏗️ Build Test Suite Results
Overall: 8/8 ecosystems passed — ✅ PASS
|
Smoke Test: GitHub Actions Services Connectivity
Overall: FAIL
|
Summary
Adds focused test coverage for two previously under-covered source files:
1.
src/commands/build-config.ts— 0% → ~95% coverageThis file was entirely uncovered (0% functions, 0% branches). The
buildConfig()function is the central config assembly point that:process.env(security-sensitive)blockedDomains,additionalEnv,excludeEnv,tty,diagnosticLogsNew test file:
src/commands/build-config.test.tscovering:blockedDomainsset toundefinedwhen empty (vs populated when non-empty)additionalEnvset toundefinedwhen empty (vs populated when non-empty)excludeEnvconditional handling (undefined/empty vs non-empty)ttyanddiagnosticLogsdefault-to-false fallbackprocess.env:OPENAI_API_KEY,ANTHROPIC_API_KEY,GEMINI_API_KEY,copilotApiKeyviaresolveCopilotApiKey()githubToken:GITHUB_TOKENtakes precedence overGH_TOKENauditDir/sessionStateDirenv var fallbacks (AWF_AUDIT_DIR,AWF_SESSION_STATE_DIR)OPENAI_API_TARGET,ANTHROPIC_API_TARGET,GEMINI_API_TARGET)volumeMounts,upstreamProxy,dnsServers,dockerHostPathPrefix,modelAliases,resolvedCopilotApiTarget2.
src/commands/predownload.ts— +4 branch coverage testsExisting tests were missing coverage for:
actpreset → pullsagent-actimage (vsagent)validateImageReference: image starting with-throwsvalidateImageReference: image with whitespace throwsCoverage Impact
build-config.tsstatementsbuild-config.tsfunctionsbuild-config.tsbranchespredownload.tsbranchesSecurity Coverage Added
resolveCopilotApiKey()is called withprocess.envGITHUB_TOKENoverGH_TOKENis now explicitly testedvalidateImageReferenceerror paths for injection-style inputs (dash prefix, whitespace) are now coveredbuildConfigfunction is what feeds credentials intoWrapperConfig— having tests here surfaces any accidental credential routing changesNo Bugs Found
No bugs were discovered in the covered code paths during test authoring.