|
1 | 1 | import { Command } from 'commander'; |
2 | | -import { parseEnvironmentVariables, parseDomains, parseDomainsFile, escapeShellArg, joinShellArgs, parseVolumeMounts, isValidIPv4, isValidIPv6, parseDnsServers, parseDnsOverHttps, validateAgentImage, isAgentImagePreset, AGENT_IMAGE_PRESETS, processAgentImageOption, processLocalhostKeyword, validateSkipPullWithBuildLocal, validateAllowHostPorts, validateAllowHostServicePorts, applyHostServicePortsConfig, parseMemoryLimit, validateFormat, validateApiProxyConfig, buildRateLimitConfig, validateRateLimitFlags, validateEnableOpenCodeFlag, hasRateLimitOptions, collectRulesetFile, validateApiTargetInAllowedDomains, DEFAULT_OPENAI_API_TARGET, DEFAULT_ANTHROPIC_API_TARGET, DEFAULT_COPILOT_API_TARGET, DEFAULT_GEMINI_API_TARGET, emitApiProxyTargetWarnings, emitCliProxyStatusLogs, warnClassicPATWithCopilotModel, formatItem, program, parseAgentTimeout, applyAgentTimeout, handlePredownloadAction, resolveApiTargetsToAllowedDomains, extractGhesDomainsFromEngineApiTarget, extractGhecDomainsFromServerUrl, checkDockerHost } from './cli'; |
| 2 | +import { parseEnvironmentVariables, parseDomains, parseDomainsFile, escapeShellArg, joinShellArgs, parseVolumeMounts, isValidIPv4, isValidIPv6, parseDnsServers, parseDnsOverHttps, validateAgentImage, isAgentImagePreset, AGENT_IMAGE_PRESETS, processAgentImageOption, processLocalhostKeyword, validateSkipPullWithBuildLocal, validateAllowHostPorts, validateAllowHostServicePorts, applyHostServicePortsConfig, parseMemoryLimit, validateFormat, validateApiProxyConfig, buildRateLimitConfig, validateRateLimitFlags, validateEnableOpenCodeFlag, hasRateLimitOptions, collectRulesetFile, validateApiTargetInAllowedDomains, DEFAULT_OPENAI_API_TARGET, DEFAULT_ANTHROPIC_API_TARGET, DEFAULT_COPILOT_API_TARGET, DEFAULT_GEMINI_API_TARGET, emitApiProxyTargetWarnings, emitCliProxyStatusLogs, warnClassicPATWithCopilotModel, formatItem, program, parseAgentTimeout, applyAgentTimeout, handlePredownloadAction, resolveApiTargetsToAllowedDomains, extractGhesDomainsFromEngineApiTarget, extractGhecDomainsFromServerUrl, checkDockerHost, validateAnthropicCacheTailTtl } from './cli'; |
3 | 3 | import { redactSecrets } from './redact-secrets'; |
4 | 4 | import * as fs from 'fs'; |
5 | 5 | import * as path from 'path'; |
@@ -2456,6 +2456,39 @@ describe('cli', () => { |
2456 | 2456 | }); |
2457 | 2457 | }); |
2458 | 2458 |
|
| 2459 | + describe('validateAnthropicCacheTailTtl', () => { |
| 2460 | + it('should not call process.exit when value is undefined', () => { |
| 2461 | + const mockExit = jest.spyOn(process, 'exit').mockImplementation((() => {}) as any); |
| 2462 | + validateAnthropicCacheTailTtl(undefined); |
| 2463 | + expect(mockExit).not.toHaveBeenCalled(); |
| 2464 | + mockExit.mockRestore(); |
| 2465 | + }); |
| 2466 | + |
| 2467 | + it('should not call process.exit for valid value "5m"', () => { |
| 2468 | + const mockExit = jest.spyOn(process, 'exit').mockImplementation((() => {}) as any); |
| 2469 | + validateAnthropicCacheTailTtl('5m'); |
| 2470 | + expect(mockExit).not.toHaveBeenCalled(); |
| 2471 | + mockExit.mockRestore(); |
| 2472 | + }); |
| 2473 | + |
| 2474 | + it('should not call process.exit for valid value "1h"', () => { |
| 2475 | + const mockExit = jest.spyOn(process, 'exit').mockImplementation((() => {}) as any); |
| 2476 | + validateAnthropicCacheTailTtl('1h'); |
| 2477 | + expect(mockExit).not.toHaveBeenCalled(); |
| 2478 | + mockExit.mockRestore(); |
| 2479 | + }); |
| 2480 | + |
| 2481 | + it('should call process.exit(1) for an invalid value', () => { |
| 2482 | + const mockExit = jest.spyOn(process, 'exit').mockImplementation((() => {}) as any); |
| 2483 | + const mockError = jest.spyOn(console, 'error').mockImplementation(() => {}); |
| 2484 | + validateAnthropicCacheTailTtl('10m'); |
| 2485 | + expect(mockError).toHaveBeenCalledWith('Invalid --anthropic-cache-tail-ttl value: "10m". Must be "5m" or "1h".'); |
| 2486 | + expect(mockExit).toHaveBeenCalledWith(1); |
| 2487 | + mockError.mockRestore(); |
| 2488 | + mockExit.mockRestore(); |
| 2489 | + }); |
| 2490 | + }); |
| 2491 | + |
2459 | 2492 | describe('formatItem', () => { |
2460 | 2493 | it('should format term with description when term fits within width', () => { |
2461 | 2494 | const result = formatItem('--flag', 'Description text', 20, 2, 2, 80); |
|
0 commit comments