docker: allow custom context name on install

Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax
2023-03-03 10:40:00 +01:00
parent fda3be9699
commit dfc72fd31c
3 changed files with 85 additions and 50 deletions

View File

@@ -21,19 +21,23 @@ import {Install} from '../../src/docker/install';
import {Docker} from '../../src/docker/docker';
// prettier-ignore
const tmpDir = path.join(process.env.TEMP || '/tmp', 'buildx-jest');
const tmpDir = path.join(process.env.TEMP || '/tmp', 'docker-install-jest');
describe('install', () => {
// prettier-ignore
test.each(['23.0.0'])(
'install docker %s', async (version) => {
await expect((async () => {
const install = new Install();
const toolPath = await install.download(version);
await install.install(toolPath, tmpDir, version);
const install = new Install({
version: version,
runDir: tmpDir,
contextName: 'foo'
});
await install.download();
await install.install();
await Docker.printVersion();
await Docker.printInfo();
await install.tearDown(tmpDir);
await install.tearDown();
})()).resolves.not.toThrow();
});
});

View File

@@ -23,7 +23,7 @@ import osm = require('os');
import {Install} from '../../src/docker/install';
// prettier-ignore
const tmpDir = path.join(process.env.TEMP || '/tmp', 'buildx-jest');
const tmpDir = path.join(process.env.TEMP || '/tmp', 'docker-install-jest');
beforeEach(() => {
jest.clearAllMocks();
@@ -43,8 +43,11 @@ describe('download', () => {
])(
'acquires %p of docker (%s)', async (version, platformOS) => {
jest.spyOn(osm, 'platform').mockImplementation(() => platformOS);
const install = new Install();
const toolPath = await install.download(version);
const install = new Install({
version: version,
runDir: tmpDir,
});
const toolPath = await install.download();
expect(fs.existsSync(toolPath)).toBe(true);
}, 100000);
});