Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions src/test/cli.podman.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import * as assert from 'assert';
import * as path from 'path';
import { chmod, writeFile } from 'fs/promises';
import { shellExec } from './testUtils';

const pkg = require('../../package.json');
Expand All @@ -14,31 +15,39 @@ describe('Dev Containers CLI using Podman', function () {

const tmp = path.relative(process.cwd(), path.join(__dirname, 'tmp'));
const cli = `npx --prefix ${tmp} devcontainer`;
const podman = process.env.GITHUB_ACTIONS === 'true' ? path.join(process.cwd(), tmp, 'podman-rootful') : 'podman';

before('Install', async () => {
await shellExec(`rm -rf ${tmp}/node_modules`);
await shellExec(`mkdir -p ${tmp}`);
if (process.env.GITHUB_ACTIONS === 'true') {
// The hosted runner's rootless Podman 5.8 build fails when APT drops
// privileges to _apt, so retain the full Feature coverage rootfully.
const podmanExecutable = (await shellExec('command -v podman')).stdout.trim();
await writeFile(podman, `#!/bin/sh\nexec sudo -- ${podmanExecutable} "$@"\n`);
await chmod(podman, 0o755);
}
await shellExec(`npm --prefix ${tmp} install devcontainers-cli-${pkg.version}.tgz`);
});

describe('Command up using Podman', () => {

it('should execute successfully with valid config with features', async () => {
const res = await shellExec(`${cli} up --docker-path podman --workspace-folder ${__dirname}/configs/image-with-features`);
const res = await shellExec(`${cli} up --docker-path ${podman} --workspace-folder ${__dirname}/configs/image-with-features`);
const response = JSON.parse(res.stdout);
assert.equal(response.outcome, 'success');
const containerId: string = response.containerId;
assert.ok(containerId, 'Container id not found.');
await shellExec(`podman rm -f ${containerId}`);
await shellExec(`${podman} rm -f ${containerId}`);
});

it('should execute successfully with valid config with features', async () => {
const res = await shellExec(`${cli} up --docker-path podman --workspace-folder ${__dirname}/configs/dockerfile-with-features`);
const res = await shellExec(`${cli} up --docker-path ${podman} --workspace-folder ${__dirname}/configs/dockerfile-with-features`);
const response = JSON.parse(res.stdout);
assert.equal(response.outcome, 'success');
const containerId: string = response.containerId;
assert.ok(containerId, 'Container id not found.');
await shellExec(`podman rm -f ${containerId}`);
await shellExec(`${podman} rm -f ${containerId}`);
});
});
});
});
Loading