|
1 | 1 | import { Command } from 'commander'; |
2 | | -import { parseEnvironmentVariables, parseDomains, parseDomainsFile, escapeShellArg, joinShellArgs, parseVolumeMounts, isValidIPv4, isValidIPv6, parseDnsServers, validateAgentImage, isAgentImagePreset, AGENT_IMAGE_PRESETS, processAgentImageOption, processLocalhostKeyword, validateSkipPullWithBuildLocal, validateAllowHostPorts, validateFormat, validateApiProxyConfig, buildRateLimitConfig, validateRateLimitFlags } from './cli'; |
| 2 | +import { parseEnvironmentVariables, parseDomains, parseDomainsFile, escapeShellArg, joinShellArgs, parseVolumeMounts, isValidIPv4, isValidIPv6, parseDnsServers, validateAgentImage, isAgentImagePreset, AGENT_IMAGE_PRESETS, processAgentImageOption, processLocalhostKeyword, validateSkipPullWithBuildLocal, validateAllowHostPorts, validateFormat, validateApiProxyConfig, buildRateLimitConfig, validateRateLimitFlags, parseAgentTimeout } from './cli'; |
3 | 3 | import { redactSecrets } from './redact-secrets'; |
4 | 4 | import * as fs from 'fs'; |
5 | 5 | import * as path from 'path'; |
@@ -1539,4 +1539,41 @@ describe('cli', () => { |
1539 | 1539 | expect(result.error).toBeUndefined(); |
1540 | 1540 | }); |
1541 | 1541 | }); |
| 1542 | + |
| 1543 | + describe('parseAgentTimeout', () => { |
| 1544 | + it('should parse a valid positive integer', () => { |
| 1545 | + const result = parseAgentTimeout('30'); |
| 1546 | + expect(result).toEqual({ minutes: 30 }); |
| 1547 | + }); |
| 1548 | + |
| 1549 | + it('should parse single minute timeout', () => { |
| 1550 | + const result = parseAgentTimeout('1'); |
| 1551 | + expect(result).toEqual({ minutes: 1 }); |
| 1552 | + }); |
| 1553 | + |
| 1554 | + it('should return error for zero', () => { |
| 1555 | + const result = parseAgentTimeout('0'); |
| 1556 | + expect(result).toEqual({ error: '--agent-timeout must be a positive integer (minutes)' }); |
| 1557 | + }); |
| 1558 | + |
| 1559 | + it('should return error for negative value', () => { |
| 1560 | + const result = parseAgentTimeout('-5'); |
| 1561 | + expect(result).toEqual({ error: '--agent-timeout must be a positive integer (minutes)' }); |
| 1562 | + }); |
| 1563 | + |
| 1564 | + it('should return error for non-numeric string', () => { |
| 1565 | + const result = parseAgentTimeout('abc'); |
| 1566 | + expect(result).toEqual({ error: '--agent-timeout must be a positive integer (minutes)' }); |
| 1567 | + }); |
| 1568 | + |
| 1569 | + it('should return error for empty string', () => { |
| 1570 | + const result = parseAgentTimeout(''); |
| 1571 | + expect(result).toEqual({ error: '--agent-timeout must be a positive integer (minutes)' }); |
| 1572 | + }); |
| 1573 | + |
| 1574 | + it('should parse large timeout values', () => { |
| 1575 | + const result = parseAgentTimeout('1440'); |
| 1576 | + expect(result).toEqual({ minutes: 1440 }); |
| 1577 | + }); |
| 1578 | + }); |
1542 | 1579 | }); |
0 commit comments