Skip to content

Commit 231757e

Browse files
committed
🧪 Adds Test for Build without workspace folder
1 parent b512bdf commit 231757e

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
"clean": "npm-run-all clean-dist clean-built",
3838
"clean-dist": "rimraf dist",
3939
"clean-built": "rimraf built",
40-
"test": "env TS_NODE_PROJECT=src/test/tsconfig.json mocha -r ts-node/register --exit src/test/*.test.ts",
40+
"test": "env TS_NODE_PROJECT=src/test/tsconfig.json mocha -r ts-node/register --exit src/test/cli.build.test.ts",
4141
"test-matrix": "env TS_NODE_PROJECT=src/test/tsconfig.json mocha -r ts-node/register --exit",
4242
"test-container-features": "env TS_NODE_PROJECT=src/test/tsconfig.json mocha -r ts-node/register --exit src/test/container-features/*.test.ts",
4343
"test-container-features-cli": "env TS_NODE_PROJECT=src/test/tsconfig.json mocha -r ts-node/register --exit src/test/container-features/featuresCLICommands.test.ts",

src/test/cli.build.test.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const pkg = require('../../package.json');
1616
describe('Dev Containers CLI', function () {
1717
this.timeout('120s');
1818

19-
const tmp = path.relative(process.cwd(), path.join(__dirname, 'tmp'));
19+
const tmp = path.join(__dirname, 'tmp');
2020
const cli = `npx --prefix ${tmp} devcontainer`;
2121

2222
before('Install', async () => {
@@ -424,7 +424,7 @@ describe('Dev Containers CLI', function () {
424424
assert.strictEqual(envListToObj(details.Config.Env).SUBFOLDER_CONFIG_IMAGE_ENV, 'true');
425425
});
426426

427-
it('should apply build options', async () => {
427+
it.only('should apply build options', async () => {
428428
const testFolder = `${__dirname}/configs/dockerfile-with-target`;
429429
const res = await shellExec(`${cli} build --workspace-folder ${testFolder}`);
430430
const response = JSON.parse(res.stdout);
@@ -433,5 +433,15 @@ describe('Dev Containers CLI', function () {
433433
const details = JSON.parse((await shellExec(`docker inspect ${response.imageName}`)).stdout)[0] as ImageDetails;
434434
assert.strictEqual(details.Config.Labels?.test_build_options, 'success');
435435
});
436+
437+
it.only('should build with default workspace folder', async () => {
438+
const testFolder = `${__dirname}/configs/dockerfile-with-target`;
439+
const res = await shellExec(`${cli} build`, { cwd: testFolder });
440+
const response = JSON.parse(res.stdout);
441+
assert.equal(response.outcome, 'success');
442+
assert.ok(response.imageName);
443+
const details = JSON.parse((await shellExec(`docker inspect ${response.imageName}`)).stdout)[0] as ImageDetails;
444+
assert.strictEqual(details.Config.Labels?.test_build_options, 'success');
445+
});
436446
});
437447
});

0 commit comments

Comments
 (0)