diff --git a/tests/fixtures/awf-runner.ts b/tests/fixtures/awf-runner.ts index a3b5cfeb..c62de681 100644 --- a/tests/fixtures/awf-runner.ts +++ b/tests/fixtures/awf-runner.ts @@ -25,6 +25,7 @@ export interface AwfOptions { noRateLimit?: boolean; // Disable rate limiting envAll?: boolean; // Pass all host environment variables to container (--env-all) cliEnv?: Record; // Explicit -e KEY=VALUE flags passed to AWF CLI + skipPull?: boolean; // Use local images without pulling from registry (--skip-pull) } export interface AwfResult { @@ -76,6 +77,10 @@ export class AwfRunner { args.push('--build-local'); } + if (options.skipPull) { + args.push('--skip-pull'); + } + if (options.imageRegistry) { args.push('--image-registry', options.imageRegistry); } @@ -256,6 +261,10 @@ export class AwfRunner { args.push('--build-local'); } + if (options.skipPull) { + args.push('--skip-pull'); + } + if (options.imageRegistry) { args.push('--image-registry', options.imageRegistry); } diff --git a/tests/integration/skip-pull.test.ts b/tests/integration/skip-pull.test.ts new file mode 100644 index 00000000..847f2592 --- /dev/null +++ b/tests/integration/skip-pull.test.ts @@ -0,0 +1,87 @@ +/** + * Skip Pull Flag Tests + * + * These tests verify the --skip-pull flag behavior: + * - Success when images are pre-downloaded (uses --build-local first to ensure images exist) + * - Error when images are not available locally + * - Rejection of --skip-pull with --build-local (incompatible flags) + */ + +/// + +import { describe, test, expect, beforeAll, afterAll } from '@jest/globals'; +import { createRunner, AwfRunner } from '../fixtures/awf-runner'; +import { cleanup } from '../fixtures/cleanup'; + +describe('Skip Pull Flag', () => { + let runner: AwfRunner; + + beforeAll(async () => { + await cleanup(false); + runner = createRunner(); + }); + + afterAll(async () => { + await cleanup(false); + }); + + test('should succeed with --skip-pull when images are pre-downloaded', async () => { + // First, ensure images exist locally by building them + const buildResult = await runner.runWithSudo( + 'echo "images built"', + { + allowDomains: ['github.com'], + buildLocal: true, + logLevel: 'debug', + timeout: 120000, + } + ); + expect(buildResult).toSucceed(); + + // Now run with --skip-pull, which should use the locally available images + const result = await runner.runWithSudo( + 'echo "skip-pull works"', + { + allowDomains: ['github.com'], + skipPull: true, + logLevel: 'debug', + timeout: 60000, + } + ); + + expect(result).toSucceed(); + expect(result.stdout).toContain('skip-pull works'); + }, 240000); + + test('should fail with --skip-pull when images are not available locally', async () => { + // Use a non-existent image tag so Docker cannot find it locally + const result = await runner.runWithSudo( + 'echo "should not reach here"', + { + allowDomains: ['github.com'], + skipPull: true, + imageTag: 'nonexistent-tag-xyz-999', + logLevel: 'debug', + timeout: 60000, + } + ); + + expect(result).toFail(); + }, 120000); + + test('should reject --skip-pull with --build-local', async () => { + const result = await runner.runWithSudo( + 'echo "should not reach here"', + { + allowDomains: ['github.com'], + skipPull: true, + buildLocal: true, + logLevel: 'debug', + timeout: 30000, + } + ); + + expect(result).toFail(); + expect(result.stderr).toContain('--skip-pull cannot be used with --build-local'); + }, 60000); +});