MCPcopy Index your code
hub / github.com/devcontainers/cli / describeTests2

Function describeTests2

src/test/cli.exec.base.ts:212–482  ·  view source on GitHub ↗
({ text, options }: BuildKitOption)

Source from the content-addressed store, hash-verified

210}
211
212export function describeTests2({ text, options }: BuildKitOption) {
213
214 describe('Dev Containers CLI', function () {
215 this.timeout('300s');
216
217 const tmp = path.relative(process.cwd(), path.join(__dirname, 'tmp'));
218 const cli = `npx --prefix ${tmp} devcontainer`;
219
220 before('Install', async () => {
221 await shellExec(`rm -rf ${tmp}/node_modules`);
222 await shellExec(`mkdir -p ${tmp}`);
223 await shellExec(`npm --prefix ${tmp} install devcontainers-cli-${pkg.version}.tgz`);
224 });
225
226 describe('Command exec', () => {
227
228 describe(`with valid (docker-compose with Dockerfile and target) config containing features [${text}]`, () => {
229 let composeProjectName: string | undefined = undefined;
230 const testFolder = `${__dirname}/configs/compose-Dockerfile-with-target`;
231 beforeEach(async () => composeProjectName = (await devContainerUp(cli, testFolder, options)).composeProjectName);
232 afterEach(async () => await devContainerDown({ composeProjectName }));
233 it('should have access to installed features (docker)', async () => {
234 const res = await shellExec(`${cli} exec --workspace-folder ${testFolder} docker --version`);
235 assert.strictEqual(res.error, null);
236 assert.match(res.stdout, /Docker version/);
237 });
238 it('should have access to installed features (hello)', async () => {
239 const res = await shellExec(`${cli} exec --workspace-folder ${testFolder} hello`);
240 assert.strictEqual(res.error, null);
241 assert.match(res.stdout, /howdy, node/);
242 });
243 it('should have marker content', async () => {
244 const res = await shellExec(`${cli} exec --workspace-folder ${testFolder} cat /var/test-marker`);
245 assert.strictEqual(res.error, null);
246 assert.match(res.stdout, /||test-content||/);
247 });
248 });
249
250
251 describe(`Dockerfile with post*Commands specified [${text}]`, () => {
252 let containerId: string | null = null;
253 const testFolder = `${__dirname}/configs/dockerfile-with-target`;
254 afterEach(async () => await devContainerDown({ containerId }));
255 it('should have all command markers at appropriate times', async () => {
256 containerId = (await devContainerUp(cli, testFolder, options)).containerId;
257 // Should have all markers (Create + Start + Attach)
258 await commandMarkerTests(cli, testFolder, { postCreate: true, postStart: true, postAttach: true }, 'Markers on first create');
259
260 // Clear markers and stop
261 await shellExec(`${cli} exec --workspace-folder ${testFolder} /bin/sh -c "rm /tmp/*.testmarker"`);
262 await devContainerStop({ containerId });
263
264 // Restart container - should have Start + Attach
265 containerId = (await devContainerUp(cli, testFolder, options)).containerId;
266 await commandMarkerTests(cli, testFolder, { postCreate: false, postStart: true, postAttach: true }, 'Markers on restart');
267
268 // TODO - investigate what triggers postAttachCommand and check test is valid
269 // // Clear markers and re-test - should have Attach

Calls 7

shellExecFunction · 0.90
devContainerUpFunction · 0.90
devContainerDownFunction · 0.90
commandMarkerTestsFunction · 0.90
devContainerStopFunction · 0.90
pathExistsFunction · 0.90
tmpdirMethod · 0.80

Tested by

no test coverage detected