Skip to content

Commit a5b0b34

Browse files
committed
🧪 Adds test for read-configuration
1 parent cdd73d8 commit a5b0b34

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-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/cli.test.ts",
40+
"test": "env TS_NODE_PROJECT=src/test/tsconfig.json mocha -r ts-node/register --exit src/test/cli.set-up.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.set-up.test.ts

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

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

1818
before('Install', async () => {
@@ -79,7 +79,7 @@ describe('Dev Containers CLI', function () {
7979
});
8080
});
8181

82-
describe('Command read-configuration', () => {
82+
describe.only('Command read-configuration', () => {
8383
it('should succeed and return postAttachCommand from config', async () => {
8484

8585
const containerId = (await shellExec(`docker run -d alpine:3.17 sleep inf`)).stdout.trim();
@@ -103,6 +103,18 @@ describe('Dev Containers CLI', function () {
103103

104104
await shellExec(`docker rm -f ${containerId}`);
105105
});
106+
107+
it('should succeed without a workspace folder', async () => {
108+
109+
await shellExec(`docker build -t devcontainer-set-up-test ${__dirname}/configs/set-up-with-metadata`);
110+
const containerId = (await shellExec(`docker run -d devcontainer-set-up-test sleep inf`)).stdout.trim();
111+
112+
const res = await shellExec(`${cli} read-configuration --include-merged-configuration`, { cwd: `${__dirname}/configs/set-up-with-metadata` });
113+
const response = JSON.parse(res.stdout);
114+
assert.strictEqual(response.mergedConfiguration.postCreateCommands.length, 1);
115+
116+
await shellExec(`docker rm -f ${containerId}`);
117+
});
106118
});
107119

108120
describe('Command exec', () => {

0 commit comments

Comments
 (0)