Skip to content

Commit ce7621e

Browse files
Jason Barnettclaude
authored andcommitted
test(git-clone): add comprehensive tests for argument combinations
Add tests covering all combinations of depth, branch_name, and clone_args to ensure the refactored run.sh properly handles all argument scenarios. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
1 parent b954ff1 commit ce7621e

File tree

1 file changed

+61
-1
lines changed

1 file changed

+61
-1
lines changed

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

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ describe("git-clone", async () => {
266266
const state = await runTerraformApply(import.meta.dir, {
267267
agent_id: "foo",
268268
url: "https://github.com/michaelbrewer/repo-tests.log",
269-
clone_args: "--depth 1 --single-branch",
269+
clone_args: "--single-branch",
270270
});
271271
const output = await executeScriptInContainer(state, "alpine/git");
272272
expect(output.exitCode).toBe(0);
@@ -275,4 +275,64 @@ describe("git-clone", async () => {
275275
"Cloning https://github.com/michaelbrewer/repo-tests.log to ~/repo-tests.log...",
276276
]);
277277
});
278+
279+
it("runs with depth", async () => {
280+
const state = await runTerraformApply(import.meta.dir, {
281+
agent_id: "foo",
282+
url: "https://github.com/michaelbrewer/repo-tests.log",
283+
depth: "1",
284+
});
285+
const output = await executeScriptInContainer(state, "alpine/git");
286+
expect(output.exitCode).toBe(0);
287+
expect(output.stdout).toEqual([
288+
"Creating directory ~/repo-tests.log...",
289+
"Cloning https://github.com/michaelbrewer/repo-tests.log to ~/repo-tests.log...",
290+
]);
291+
});
292+
293+
it("runs with depth and branch_name", async () => {
294+
const state = await runTerraformApply(import.meta.dir, {
295+
agent_id: "foo",
296+
url: "https://github.com/michaelbrewer/repo-tests.log",
297+
branch_name: "feat/branch",
298+
depth: "1",
299+
});
300+
const output = await executeScriptInContainer(state, "alpine/git");
301+
expect(output.exitCode).toBe(0);
302+
expect(output.stdout).toEqual([
303+
"Creating directory ~/repo-tests.log...",
304+
"Cloning https://github.com/michaelbrewer/repo-tests.log to ~/repo-tests.log on branch feat/branch...",
305+
]);
306+
});
307+
308+
it("runs with clone_args and branch_name", async () => {
309+
const state = await runTerraformApply(import.meta.dir, {
310+
agent_id: "foo",
311+
url: "https://github.com/michaelbrewer/repo-tests.log",
312+
branch_name: "feat/branch",
313+
clone_args: "--single-branch",
314+
});
315+
const output = await executeScriptInContainer(state, "alpine/git");
316+
expect(output.exitCode).toBe(0);
317+
expect(output.stdout).toEqual([
318+
"Creating directory ~/repo-tests.log...",
319+
"Cloning https://github.com/michaelbrewer/repo-tests.log to ~/repo-tests.log on branch feat/branch...",
320+
]);
321+
});
322+
323+
it("runs with depth, branch_name, and clone_args", async () => {
324+
const state = await runTerraformApply(import.meta.dir, {
325+
agent_id: "foo",
326+
url: "https://github.com/michaelbrewer/repo-tests.log",
327+
branch_name: "feat/branch",
328+
depth: "1",
329+
clone_args: "--single-branch",
330+
});
331+
const output = await executeScriptInContainer(state, "alpine/git");
332+
expect(output.exitCode).toBe(0);
333+
expect(output.stdout).toEqual([
334+
"Creating directory ~/repo-tests.log...",
335+
"Cloning https://github.com/michaelbrewer/repo-tests.log to ~/repo-tests.log on branch feat/branch...",
336+
]);
337+
});
278338
});

0 commit comments

Comments
 (0)