From ca1d4547cbece8f920de251298249b68a67cabce Mon Sep 17 00:00:00 2001 From: Stephen Kirby Date: Tue, 26 Sep 2023 22:58:26 +0000 Subject: [PATCH] started test, standardized git not installed message --- git-config/main.test.ts | 37 +++++++++++++++++++++++++++++++++++++ git-config/run.sh | 2 +- 2 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 git-config/main.test.ts diff --git a/git-config/main.test.ts b/git-config/main.test.ts new file mode 100644 index 0000000..deaf250 --- /dev/null +++ b/git-config/main.test.ts @@ -0,0 +1,37 @@ +import { describe, expect, it } from "bun:test"; +import { + executeScriptInContainer, + runTerraformApply, + runTerraformInit, + testRequiredVariables, +} from "../test"; + +describe("git-config", async () => { + await runTerraformInit(import.meta.dir); + + testRequiredVariables(import.meta.dir, { + agent_id: "foo", + }); + + it("fails without git", async () => { + const state = await runTerraformApply(import.meta.dir, { + agent_id: "foo", + }); + const output = await executeScriptInContainer(state, "alpine"); + expect(output.exitCode).toBe(1); + expect(output.stdout).toEqual(["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...", +// ]); +// }); +}); diff --git a/git-config/run.sh b/git-config/run.sh index 6bba880..cf5cfd0 100644 --- a/git-config/run.sh +++ b/git-config/run.sh @@ -5,7 +5,7 @@ printf "$${BOLD}Checking git-config!\n" # Check if git is installed command -v git >/dev/null 2>&1 || { - echo "git is not installed! Install git to sync username and email.\n" + echo "Git is not installed!" exit 1 }