Skip to content

Commit e9c1405

Browse files
committed
docker/install: Add tests for installing from image
Signed-off-by: Paweł Gronowski <[email protected]>
1 parent 02667ee commit e9c1405

File tree

2 files changed

+37
-19
lines changed

2 files changed

+37
-19
lines changed

__tests__/docker/install.test.itg.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import fs from 'fs';
1919
import os from 'os';
2020
import path from 'path';
2121

22-
import {Install} from '../../src/docker/install';
22+
import {Install, InstallSourceArchive, InstallSourceImage} from '../../src/docker/install';
2323
import {Docker} from '../../src/docker/docker';
2424
import {Exec} from '../../src/exec';
2525

@@ -40,8 +40,11 @@ aarch64:https://cloud.debian.org/images/cloud/bookworm/20231013-1532/debian-12-g
4040
process.env = originalEnv;
4141
});
4242
// prettier-ignore
43-
test.each(['v26.1.4'])(
44-
'install docker %s', async (version) => {
43+
test.each([
44+
{type: 'archive', version: 'v26.1.4', channel: 'stable'} as InstallSourceArchive,
45+
{type: 'image', tag: 'v27.3.1'} as InstallSourceImage,
46+
])(
47+
'install docker %s', async (source) => {
4548
if (process.env.ImageOS && process.env.ImageOS.startsWith('ubuntu')) {
4649
// Remove containerd first on ubuntu runners to make sure it takes
4750
// ones packaged with docker
@@ -55,11 +58,7 @@ aarch64:https://cloud.debian.org/images/cloud/bookworm/20231013-1532/debian-12-g
5558
}
5659
await expect((async () => {
5760
const install = new Install({
58-
source: {
59-
type: 'archive',
60-
version: version,
61-
channel: 'stable',
62-
},
61+
source: source,
6362
runDir: tmpDir,
6463
contextName: 'foo',
6564
daemonConfig: `{"debug":true,"features":{"containerd-snapshotter":true}}`

__tests__/docker/install.test.ts

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,30 +21,49 @@ import path from 'path';
2121
import * as rimraf from 'rimraf';
2222
import osm = require('os');
2323

24-
import {Install} from '../../src/docker/install';
24+
import {Install, InstallSource, InstallSourceArchive, InstallSourceImage} from '../../src/docker/install';
2525

2626
const tmpDir = fs.mkdtempSync(path.join(process.env.TEMP || os.tmpdir(), 'docker-install-'));
2727

2828
afterEach(function () {
2929
rimraf.sync(tmpDir);
3030
});
3131

32+
const archive = (version: string, channel: string): InstallSourceArchive => {
33+
return {
34+
type: 'archive',
35+
version: version,
36+
channel: channel
37+
};
38+
};
39+
40+
const image = (tag: string): InstallSourceImage => {
41+
return {
42+
type: 'image',
43+
tag: tag
44+
};
45+
};
46+
3247
describe('download', () => {
3348
// prettier-ignore
3449
test.each([
35-
['v19.03.14', 'linux'],
36-
['v20.10.22', 'linux'],
37-
['v20.10.22', 'darwin'],
38-
['v20.10.22', 'win32'],
50+
[archive('v19.03.14', 'stable'), 'linux'],
51+
[archive('v20.10.22', 'stable'), 'linux'],
52+
[archive('v20.10.22', 'stable'), 'darwin'],
53+
[archive('v20.10.22', 'stable'), 'win32'],
54+
55+
[image('master'), 'linux'],
56+
[image('master'), 'darwin'],
57+
[image('master'), 'win32'],
58+
59+
[image('v27.3.1'), 'linux'],
60+
[image('v27.3.1'), 'darwin'],
61+
[image('v27.3.1'), 'win32'],
3962
])(
40-
'acquires %p of docker (%s)', async (version, platformOS) => {
63+
'acquires %p of docker (%s)', async (source, platformOS) => {
4164
jest.spyOn(osm, 'platform').mockImplementation(() => platformOS as NodeJS.Platform);
4265
const install = new Install({
43-
source: {
44-
type: 'archive',
45-
version: version,
46-
channel: 'stable',
47-
},
66+
source: source,
4867
runDir: tmpDir,
4968
});
5069
const toolPath = await install.download();

0 commit comments

Comments
 (0)