Skip to content
This repository was archived by the owner on May 15, 2025. It is now read-only.

Commit 36b612d

Browse files
fix: tests
1 parent b0bd714 commit 36b612d

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

devcontainers-cli/main.test.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,21 @@ const executeScriptInContainerWithPackageManager = async (
4040
]);
4141
}
4242

43-
const resp = await execContainer(id, [shell, "-c", instance.script]);
43+
const pathResp = await execContainer(id, [shell, "-c", "echo $PATH"]);
44+
const path = pathResp.stdout.trim();
45+
46+
console.log(path);
47+
48+
const resp = await execContainer(
49+
id,
50+
[shell, "-c", instance.script],
51+
[
52+
"--env",
53+
"CODER_SCRIPT_BIN_DIR=/tmp/coder-script-data/bin",
54+
"--env",
55+
`PATH=${path}:/tmp/coder-script-data/bin`,
56+
],
57+
);
4458
const stdout = resp.stdout.trim().split("\n");
4559
const stderr = resp.stderr.trim().split("\n");
4660
return {
@@ -98,13 +112,14 @@ describe("devcontainers-cli", async () => {
98112
"docker:dind",
99113
"yarn",
100114
);
115+
console.log(output);
101116
expect(output.exitCode).toBe(0);
102117

103118
expect(output.stdout[0]).toEqual(
104119
"Installing @devcontainers/cli using yarn...",
105120
);
106121
expect(output.stdout[output.stdout.length - 1]).toEqual(
107-
"🥳 @devcontainers/cli has been installed into /usr/local/bin/devcontainer!",
122+
"🥳 @devcontainers/cli has been installed into /tmp/coder-script-data/bin/devcontainer!",
108123
);
109124
}, 15000);
110125

test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,13 @@ export const executeScriptInContainer = async (
6666
export const execContainer = async (
6767
id: string,
6868
cmd: string[],
69+
args?: string[],
6970
): Promise<{
7071
exitCode: number;
7172
stderr: string;
7273
stdout: string;
7374
}> => {
74-
const proc = spawn(["docker", "exec", id, ...cmd], {
75+
const proc = spawn(["docker", "exec", ...(args ?? []), id, ...cmd], {
7576
stderr: "pipe",
7677
stdout: "pipe",
7778
});

0 commit comments

Comments
 (0)