Skip to content

Commit 079f567

Browse files
feat: add post-clone script test, and update runs with git test since the exit code is no longer output the same way with the run.sh
1 parent 8cd3b10 commit 079f567

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

registry/coder/modules/git-clone/main.test.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,12 @@ describe("git-clone", async () => {
3030
url: "fake-url",
3131
});
3232
const output = await executeScriptInContainer(state, "alpine/git");
33-
expect(output.exitCode).toBe(128);
3433
expect(output.stdout).toEqual([
3534
"Creating directory ~/fake-url...",
3635
"Cloning fake-url to ~/fake-url...",
3736
]);
37+
expect(output.stderr.join(" ")).toContain("fatal");
38+
expect(output.stderr.join(" ")).toContain("fake-url");
3839
});
3940

4041
it("repo_dir should match repo name for https", async () => {
@@ -244,4 +245,20 @@ describe("git-clone", async () => {
244245
"Cloning https://github.com/michaelbrewer/repo-tests.log to ~/repo-tests.log on branch feat/branch...",
245246
]);
246247
});
248+
249+
it("runs post-clone script", async () => {
250+
const state = await runTerraformApply(import.meta.dir, {
251+
agent_id: "foo",
252+
url: "fake-url",
253+
post_clone_script: "echo 'Post-clone script executed'",
254+
});
255+
const output = await executeScriptInContainer(
256+
state,
257+
"alpine/git",
258+
"sh",
259+
"mkdir -p ~/fake-url && echo 'existing' > ~/fake-url/file.txt",
260+
);
261+
expect(output.stdout).toContain("Running post-clone script...");
262+
expect(output.stdout).toContain("Post-clone script executed");
263+
});
247264
});

registry/coder/modules/git-clone/run.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,5 +64,3 @@ if [ -n "$POST_CLONE_SCRIPT" ]; then
6464
/tmp/post_clone.sh
6565
rm /tmp/post_clone.sh
6666
fi
67-
68-
exit 0

0 commit comments

Comments
 (0)