Skip to content

Commit 177e1f2

Browse files
Mossakaclaude
andauthored
test: add --skip-pull integration test (#1222)
Add integration tests for the --skip-pull flag covering: - Success when images are pre-downloaded (build-local first, then skip-pull) - Error when images are not available locally (non-existent tag) - Rejection of --skip-pull with --build-local (incompatible flags) Also adds skipPull option to AwfRunner in both run() and runWithSudo(). Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent d2c5d3c commit 177e1f2

File tree

2 files changed

+96
-0
lines changed

2 files changed

+96
-0
lines changed

tests/fixtures/awf-runner.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export interface AwfOptions {
2525
noRateLimit?: boolean; // Disable rate limiting
2626
envAll?: boolean; // Pass all host environment variables to container (--env-all)
2727
cliEnv?: Record<string, string>; // Explicit -e KEY=VALUE flags passed to AWF CLI
28+
skipPull?: boolean; // Use local images without pulling from registry (--skip-pull)
2829
}
2930

3031
export interface AwfResult {
@@ -76,6 +77,10 @@ export class AwfRunner {
7677
args.push('--build-local');
7778
}
7879

80+
if (options.skipPull) {
81+
args.push('--skip-pull');
82+
}
83+
7984
if (options.imageRegistry) {
8085
args.push('--image-registry', options.imageRegistry);
8186
}
@@ -256,6 +261,10 @@ export class AwfRunner {
256261
args.push('--build-local');
257262
}
258263

264+
if (options.skipPull) {
265+
args.push('--skip-pull');
266+
}
267+
259268
if (options.imageRegistry) {
260269
args.push('--image-registry', options.imageRegistry);
261270
}
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
/**
2+
* Skip Pull Flag Tests
3+
*
4+
* These tests verify the --skip-pull flag behavior:
5+
* - Success when images are pre-downloaded (uses --build-local first to ensure images exist)
6+
* - Error when images are not available locally
7+
* - Rejection of --skip-pull with --build-local (incompatible flags)
8+
*/
9+
10+
/// <reference path="../jest-custom-matchers.d.ts" />
11+
12+
import { describe, test, expect, beforeAll, afterAll } from '@jest/globals';
13+
import { createRunner, AwfRunner } from '../fixtures/awf-runner';
14+
import { cleanup } from '../fixtures/cleanup';
15+
16+
describe('Skip Pull Flag', () => {
17+
let runner: AwfRunner;
18+
19+
beforeAll(async () => {
20+
await cleanup(false);
21+
runner = createRunner();
22+
});
23+
24+
afterAll(async () => {
25+
await cleanup(false);
26+
});
27+
28+
test('should succeed with --skip-pull when images are pre-downloaded', async () => {
29+
// First, ensure images exist locally by building them
30+
const buildResult = await runner.runWithSudo(
31+
'echo "images built"',
32+
{
33+
allowDomains: ['github.com'],
34+
buildLocal: true,
35+
logLevel: 'debug',
36+
timeout: 120000,
37+
}
38+
);
39+
expect(buildResult).toSucceed();
40+
41+
// Now run with --skip-pull, which should use the locally available images
42+
const result = await runner.runWithSudo(
43+
'echo "skip-pull works"',
44+
{
45+
allowDomains: ['github.com'],
46+
skipPull: true,
47+
logLevel: 'debug',
48+
timeout: 60000,
49+
}
50+
);
51+
52+
expect(result).toSucceed();
53+
expect(result.stdout).toContain('skip-pull works');
54+
}, 240000);
55+
56+
test('should fail with --skip-pull when images are not available locally', async () => {
57+
// Use a non-existent image tag so Docker cannot find it locally
58+
const result = await runner.runWithSudo(
59+
'echo "should not reach here"',
60+
{
61+
allowDomains: ['github.com'],
62+
skipPull: true,
63+
imageTag: 'nonexistent-tag-xyz-999',
64+
logLevel: 'debug',
65+
timeout: 60000,
66+
}
67+
);
68+
69+
expect(result).toFail();
70+
}, 120000);
71+
72+
test('should reject --skip-pull with --build-local', async () => {
73+
const result = await runner.runWithSudo(
74+
'echo "should not reach here"',
75+
{
76+
allowDomains: ['github.com'],
77+
skipPull: true,
78+
buildLocal: true,
79+
logLevel: 'debug',
80+
timeout: 30000,
81+
}
82+
);
83+
84+
expect(result).toFail();
85+
expect(result.stderr).toContain('--skip-pull cannot be used with --build-local');
86+
}, 60000);
87+
});

0 commit comments

Comments
 (0)