mirror of
https://github.com/docker/actions-toolkit.git
synced 2024-11-23 03:16:09 +08:00
docker/install: Add tests for installing from image
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
This commit is contained in:
parent
de390e0872
commit
b143889d3e
@ -19,7 +19,7 @@ import fs from 'fs';
|
||||
import os from 'os';
|
||||
import path from 'path';
|
||||
|
||||
import {Install} from '../../src/docker/install';
|
||||
import {Install, InstallSourceArchive, InstallSourceImage} from '../../src/docker/install';
|
||||
import {Docker} from '../../src/docker/docker';
|
||||
import {Exec} from '../../src/exec';
|
||||
|
||||
@ -40,8 +40,11 @@ aarch64:https://cloud.debian.org/images/cloud/bookworm/20231013-1532/debian-12-g
|
||||
process.env = originalEnv;
|
||||
});
|
||||
// prettier-ignore
|
||||
test.each(['v26.1.4'])(
|
||||
'install docker %s', async (version) => {
|
||||
test.each([
|
||||
{type: 'archive', version: 'v26.1.4', channel: 'stable'} as InstallSourceArchive,
|
||||
{type: 'image', tag: '27.3.1'} as InstallSourceImage,
|
||||
])(
|
||||
'install docker %s', async (source) => {
|
||||
if (process.env.ImageOS && process.env.ImageOS.startsWith('ubuntu')) {
|
||||
// Remove containerd first on ubuntu runners to make sure it takes
|
||||
// ones packaged with docker
|
||||
@ -55,11 +58,7 @@ aarch64:https://cloud.debian.org/images/cloud/bookworm/20231013-1532/debian-12-g
|
||||
}
|
||||
await expect((async () => {
|
||||
const install = new Install({
|
||||
source: {
|
||||
type: 'archive',
|
||||
version: version,
|
||||
channel: 'stable',
|
||||
},
|
||||
source: source,
|
||||
runDir: tmpDir,
|
||||
contextName: 'foo',
|
||||
daemonConfig: `{"debug":true,"features":{"containerd-snapshotter":true}}`
|
||||
|
@ -21,7 +21,7 @@ import path from 'path';
|
||||
import * as rimraf from 'rimraf';
|
||||
import osm = require('os');
|
||||
|
||||
import {Install} from '../../src/docker/install';
|
||||
import {Install, InstallSourceArchive, InstallSourceImage} from '../../src/docker/install';
|
||||
|
||||
const tmpDir = fs.mkdtempSync(path.join(process.env.TEMP || os.tmpdir(), 'docker-install-'));
|
||||
|
||||
@ -29,22 +29,39 @@ afterEach(function () {
|
||||
rimraf.sync(tmpDir);
|
||||
});
|
||||
|
||||
const archive = (version: string, channel: string): InstallSourceArchive => {
|
||||
return {
|
||||
type: 'archive',
|
||||
version: version,
|
||||
channel: channel
|
||||
};
|
||||
};
|
||||
|
||||
const image = (tag: string): InstallSourceImage => {
|
||||
return {
|
||||
type: 'image',
|
||||
tag: tag
|
||||
};
|
||||
};
|
||||
|
||||
describe('download', () => {
|
||||
// prettier-ignore
|
||||
test.each([
|
||||
['v19.03.14', 'linux'],
|
||||
['v20.10.22', 'linux'],
|
||||
['v20.10.22', 'darwin'],
|
||||
['v20.10.22', 'win32'],
|
||||
[archive('v19.03.14', 'stable'), 'linux'],
|
||||
[archive('v20.10.22', 'stable'), 'linux'],
|
||||
[archive('v20.10.22', 'stable'), 'darwin'],
|
||||
[archive('v20.10.22', 'stable'), 'win32'],
|
||||
|
||||
[image('master'), 'linux'],
|
||||
[image('master'), 'win32'],
|
||||
|
||||
[image('27.3.1'), 'linux'],
|
||||
[image('27.3.1'), 'win32'],
|
||||
])(
|
||||
'acquires %p of docker (%s)', async (version, platformOS) => {
|
||||
'acquires %p of docker (%s)', async (source, platformOS) => {
|
||||
jest.spyOn(osm, 'platform').mockImplementation(() => platformOS as NodeJS.Platform);
|
||||
const install = new Install({
|
||||
source: {
|
||||
type: 'archive',
|
||||
version: version,
|
||||
channel: 'stable',
|
||||
},
|
||||
source: source,
|
||||
runDir: tmpDir,
|
||||
});
|
||||
const toolPath = await install.download();
|
||||
|
Loading…
Reference in New Issue
Block a user