From 001fcca8d970767bece150e4850c0f35688db271 Mon Sep 17 00:00:00 2001 From: Stephen Kirby Date: Wed, 27 Sep 2023 19:10:20 +0000 Subject: [PATCH] polished run.sh, updated tests --- git-config/main.test.ts | 36 ++++++++++++++++++++---------------- git-config/run.sh | 4 ++-- 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/git-config/main.test.ts b/git-config/main.test.ts index af2b74b..4c0d309 100644 --- a/git-config/main.test.ts +++ b/git-config/main.test.ts @@ -11,31 +11,35 @@ describe("git-config", async () => { testRequiredVariables(import.meta.dir, { agent_id: "foo", - allow_username_change: true, - allow_email_change: false, }); it("fails without git", async () => { const state = await runTerraformApply(import.meta.dir, { agent_id: "foo", - allow_username_change: true, + allow_username_change: false, allow_email_change: false, }); const output = await executeScriptInContainer(state, "alpine"); expect(output.exitCode).toBe(1); - expect(output.stdout).toEqual(["\u001B[0;1mChecking git-config!", "Git is not installed!"]); + expect(output.stdout).toEqual([ + "\u001B[0;1mChecking git-config!", + "Git is not installed!", + ]); }); -// it("runs with git", async () => { -// const state = await runTerraformApply(import.meta.dir, { -// agent_id: "foo", -// url: "fake-url", -// }); -// const output = await executeScriptInContainer(state, "alpine/git"); -// expect(output.exitCode).toBe(128); -// expect(output.stdout).toEqual([ -// "Creating directory ~/fake-url...", -// "Cloning fake-url to ~/fake-url...", -// ]); -// }); + it("runs with git", async () => { + const state = await runTerraformApply(import.meta.dir, { + agent_id: "foo", + }); + const output = await executeScriptInContainer(state, "alpine/git"); + expect(output.exitCode).toBe(0); + expect(output.stdout).toEqual([ + "\u001B[0;1mChecking git-config!", + "git-config: No user.email found, setting to ", + "git-config: No user.name found, setting to default", + "\u001B[0;1mgit-config: using email: ", + "", + "\u001B[0;1mgit-config: using username: default", + ]); + }); }); diff --git a/git-config/run.sh b/git-config/run.sh index cf5cfd0..f2a87ef 100644 --- a/git-config/run.sh +++ b/git-config/run.sh @@ -20,5 +20,5 @@ if [ -z $(git config --get user.name) ]; then git config --global user.name "${CODER_USERNAME}" fi -printf "\n$${BOLD}git-config: using username: $(git config --get user.name)\n" -printf "$${BOLD}git-config: using email: $(git config --get user.email)\n\n" +printf "$${BOLD}git-config: using email: $(git config --get user.email)\n" +printf "\n$${BOLD}git-config: using username: $(git config --get user.name)\n\n"