[Test Coverage] Add comprehensive tests for config-assembly validator#3670
Conversation
- Add 28 test cases covering validation error paths - Test docker-host URI validation (unix:// requirement) - Test docker-host-path-prefix validation (absolute path requirement) - Test rate limit configuration error handling - Test feature flag validation (opencode, token-steering) - Test environment variable warnings (--env-all, --env-file) - Test host service ports and host ports validation - Test skip-pull + build-local incompatibility - Test host access warnings with host.docker.internal - Test API proxy configuration logging - Test COPILOT_MODEL detection from multiple sources: - env files (with export prefix, comments) - --env flags - host environment (with --env-all) - array of env files - unreadable files (graceful handling) Coverage improvement: config-assembly.ts - Statement coverage: 81% → ~95% - Branch coverage: 65% → ~90% All tests use proper mocking patterns and follow existing test conventions in the codebase. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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 a new Jest unit test suite targeting assembleAndValidateConfig (src/commands/validators/config-assembly.ts) to increase coverage of post-assembly validation and warning paths in the CLI validation pipeline.
Changes:
- Introduces a new
config-assembly.test.tswith extensive mocking ofbuildConfig,option-parsers,api-proxy-config, andlogger. - Adds test cases covering docker-host/path-prefix guards, rate-limit assembly, feature-flag compatibility checks, host-access/ports validation, API proxy status logging, and COPILOT_MODEL detection paths.
Show a summary per file
| File | Description |
|---|---|
| src/commands/validators/config-assembly.test.ts | Adds a comprehensive Jest test suite for post-assembly validation behavior in assembleAndValidateConfig. |
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: 4
| localhostResult: { localhostDetected: false, domains: [] }, | ||
| upstreamProxy: undefined, | ||
| dnsServers: ['8.8.8.8'], | ||
| dnsOverHttps: undefined, | ||
| resolvedCopilotApiTarget: undefined, | ||
| resolvedCopilotApiBasePath: undefined, | ||
| dockerHostPathPrefixResolution: { dockerHostPathPrefix: undefined }, |
| mockBuildConfig.mockReturnValueOnce({ | ||
| envAll: true, | ||
| copilotGithubToken: 'ghp_testtoken', | ||
| }); | ||
|
|
||
| assembleAndValidateConfig( | ||
| {}, | ||
| 'echo test', | ||
| createMinimalLogAndLimits(), | ||
| createMinimalNetworkOptions(), | ||
| createMinimalAgentOptions(), | ||
| ); | ||
|
|
||
| expect(warnClassicPATWithCopilotModel).toHaveBeenCalledWith( | ||
| true, | ||
| true, // COPILOT_MODEL detected from host env | ||
| expect.any(Function), | ||
| ); | ||
|
|
||
| // Cleanup | ||
| if (originalCopilotModel) { | ||
| process.env.COPILOT_MODEL = originalCopilotModel; | ||
| } else { | ||
| delete process.env.COPILOT_MODEL; |
| allowHostServicePorts: [], | ||
| enableHostAccess: false, | ||
| allowHostPorts: [], |
| mockBuildConfig.mockReturnValueOnce({ | ||
| awfDockerHost: 'tcp://127.0.0.1:2375', | ||
| dockerHostPathPrefix: undefined, | ||
| }); | ||
|
|
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.
|
@copilot address review feedback |
Addressed in fd9de14. I updated
Validation run:
|
✅ Coverage Check PassedOverall Coverage
📁 Per-file Coverage Changes (2 files)
Coverage comparison generated by |
Smoke Test ResultsMCP Connectivity: ✅ Retrieved PR #3667 - [docs] Document Anthropic deprecated beta header retry handling Overall Status: ❌ FAIL
|
Smoke Test Results✅ GitHub API: Recent PRs validated (2 entries found) Overall Result: ✅ PASS
|
Smoke Test: Copilot BYOK (Offline Mode) ✅Status: PASS Test Results✅ GitHub MCP — Retrieved PR #3689: "fix(api-proxy): generalize deprecated header stripping for any provider/header" Note: Running in BYOK offline mode ( PR Context: #3670 by
|
|
PRs: [docs] Document Anthropic deprecated beta header retry handling | Retry Anthropic requests after deprecated 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: FAIL. Connectivity and MCP tool issues. 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 Version Comparison Test Results
Overall Result: ❌ FAILED (not all versions match) The chroot environment does not have identical runtime versions to the host. Python and Node.js versions differ between the host and chroot environments, which could lead to inconsistencies in agent behavior.
|
🔥 Service Connectivity Test Results❌ Redis (host.docker.internal:6379) — timeout Overall: ❌ FAILAll service connectivity checks failed. Services on host.docker.internal are not reachable from the AWF sandbox.
|
🏗️ Build Test Suite Results
Overall: 8/8 ecosystems passed — ✅ PASS All build and test operations completed successfully across all ecosystems.
|
Summary
Adds 28 comprehensive test cases for
src/commands/validators/config-assembly.ts, improving coverage from 81% to ~95% for statements and 65% to ~90% for branches.Test Coverage Added
Docker Host Validation
Rate Limit Configuration
Feature Flag Validation
Environment Variable Handling
Host Access & Ports
Build Configuration
API Proxy
COPILOT_MODEL Detection (Security-Critical)
Coverage Impact
Before:
After (estimated):
Overall project impact: +0.5% to +1% total coverage
Testing Approach
Security Focus
These tests are particularly important because config-assembly.ts is the final validation stage for all CLI options before execution. It guards against:
Validation
Related
Part of ongoing test coverage improvement initiative. Targets security-critical validation code paths.