tests WIP
This commit is contained in:
31
coder-login/main.test.ts
Normal file
31
coder-login/main.test.ts
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
import { describe, expect, it } from "bun:test";
|
||||||
|
import {
|
||||||
|
executeScriptInContainer,
|
||||||
|
runTerraformApply,
|
||||||
|
runTerraformInit,
|
||||||
|
testRequiredVariables,
|
||||||
|
} from "../test";
|
||||||
|
|
||||||
|
describe("git-clone", async () => {
|
||||||
|
await runTerraformInit(import.meta.dir);
|
||||||
|
|
||||||
|
testRequiredVariables(import.meta.dir, {
|
||||||
|
agent_id: "foo",
|
||||||
|
});
|
||||||
|
|
||||||
|
it("runs with default", async () => {
|
||||||
|
const state = await runTerraformApply(import.meta.dir, {
|
||||||
|
agent_id: "foo",
|
||||||
|
});
|
||||||
|
const output = await executeScriptInContainer(state, "alpine");
|
||||||
|
// expect(output.exitCode).toBe(0);
|
||||||
|
expect(output.stderr).toEqual([
|
||||||
|
""
|
||||||
|
]);
|
||||||
|
expect(output.stdout).toEqual([
|
||||||
|
"Authenticating with Coder...",
|
||||||
|
"",
|
||||||
|
""
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -3,14 +3,16 @@
|
|||||||
# Automatically authenticate the user if they are not
|
# Automatically authenticate the user if they are not
|
||||||
# logged in to another deployment
|
# logged in to another deployment
|
||||||
|
|
||||||
echo "Logging into Coder..."
|
CODER_DEPLOYMENT_URL=("${CODER_DEPLOYMENT_URL}")
|
||||||
|
CODER_USER_TOKEN=("${CODER_USER_TOKEN}")
|
||||||
|
RESET='\033[0m'
|
||||||
|
BOLD='\033[0;1m'
|
||||||
|
|
||||||
|
printf "$${BOLD}Logging into Coder...\n\n$${RESET}"
|
||||||
|
|
||||||
echo "SESSION TOKEN : ${CODER_USER_TOKEN}"
|
|
||||||
echo "DEPLOYMENT URL: ${CODER_DEPLOYMENT_URL}"
|
|
||||||
echo ""
|
|
||||||
|
|
||||||
if ! coder list >/dev/null 2>&1; then
|
if ! coder list >/dev/null 2>&1; then
|
||||||
set +x; coder login --token="${CODER_USER_TOKEN}" --url="${CODER_DEPLOYMENT_URL}"
|
set +x; coder login --token="${CODER_USER_TOKEN}" --url="${CODER_DEPLOYMENT_URL}"
|
||||||
else
|
else
|
||||||
echo "You are already authenticated with coder"
|
echo "You are already authenticated with coder."
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user