diff --git a/fly-region/main.test.ts b/fly-region/main.test.ts index 774490b..7e72586 100644 --- a/fly-region/main.test.ts +++ b/fly-region/main.test.ts @@ -25,7 +25,7 @@ describe("fly-region", async () => { it("region filter", async () => { const state = await runTerraformApply(import.meta.dir, { default: "atl", - regions: '["arn", "ams", "bos"]' + regions: '["arn", "ams", "bos"]', }); expect(state.outputs.value.value).toBe(""); }); diff --git a/jupyterlab/main.test.ts b/jupyterlab/main.test.ts new file mode 100644 index 0000000..15fb487 --- /dev/null +++ b/jupyterlab/main.test.ts @@ -0,0 +1,57 @@ +import { describe, expect, it } from "bun:test"; +import { + executeScriptInContainer, + runTerraformApply, + runTerraformInit, + testRequiredVariables, + findResourceInstance, + runContainer, +} from "../test"; + +const executeScriptInContainer = async ( + state: TerraformState, + image: string, + shell: string = "sh", +): Promise<{ + exitCode: number; + stdout: string[]; + stderr: string[]; +}> => { + const instance = findResourceInstance(state, "coder_script"); + const id = await runContainer(image); + const resp = await execContainer(id, [shell, "-c", instance.script]); + const stdout = resp.stdout.trim().split("\n"); + const stderr = resp.stderr.trim().split("\n"); + return { + exitCode: resp.exitCode, + stdout, + stderr, + }; +}; + +describe("jupyterlab", async () => { + await runTerraformInit(import.meta.dir); + + testRequiredVariables(import.meta.dir, { + agent_id: "foo", + }); + + it("fails without pip3", async () => { + const state = await runTerraformApply(import.meta.dir, { + agent_id: "foo", + }); + + const instance = findResourceInstance(state, "coder_script"); + const id = await runContainer("alpine"); + const output = await executeScriptInContainer(state, "alpine"); + expect(output.exitCode).toBe(1); + expect(output.stdout).toEqual([ + "\u001B[0;1mInstalling jupyterlab!", + "pip3 is not installed", + "Please install pip3 in your Dockerfile/VM image before running this script", + ]); + }); + + // TODO: Add test that runs with pip + // May be best to use dockerfile +}); diff --git a/vscode-desktop/main.test.ts b/vscode-desktop/main.test.ts index ac4133f..304655d 100644 --- a/vscode-desktop/main.test.ts +++ b/vscode-desktop/main.test.ts @@ -13,15 +13,12 @@ describe("vscode-desktop", async () => { agent_id: "foo", }); - it("default output", async () => { const state = await runTerraformApply(import.meta.dir, { agent_id: "foo", }); expect(state.outputs.vscode_url.value).toBe( - "vscode://coder.coder-remote/open?owner=default&workspace=default&token=$SESSION_TOKEN" + "vscode://coder.coder-remote/open?owner=default&workspace=default&token=$SESSION_TOKEN", ); }); - - }); diff --git a/vscode-desktop/main.tf b/vscode-desktop/main.tf index cc3340a..715fb14 100644 --- a/vscode-desktop/main.tf +++ b/vscode-desktop/main.tf @@ -46,6 +46,6 @@ resource "coder_app" "vscode" { } output "vscode_url" { - value = coder_app.vscode.url + value = coder_app.vscode.url description = "VS Code Desktop URL." } diff --git a/vscode-web/main.test.ts b/vscode-web/main.test.ts index dd31e86..57277df 100644 --- a/vscode-web/main.test.ts +++ b/vscode-web/main.test.ts @@ -8,7 +8,6 @@ import { describe("vscode-web", async () => { await runTerraformInit(import.meta.dir); - // replaces testRequiredVariables due to license variable // may add a testRequiredVariablesWithLicense function later it("missing agent_id", async () => { @@ -17,21 +16,18 @@ describe("vscode-web", async () => { accept_license: "true", }); } catch (ex) { - expect(ex.message).toContain( - 'input variable "agent_id" is not set' - ); + expect(ex.message).toContain('input variable "agent_id" is not set'); } }); it("invalid license_agreement", async () => { - try { await runTerraformApply(import.meta.dir, { agent_id: "foo", }); } catch (ex) { expect(ex.message).toContain( - 'You must accept the VS Code license agreement by setting accept_license=true' + "You must accept the VS Code license agreement by setting accept_license=true", ); } }); @@ -61,8 +57,7 @@ describe("vscode-web", async () => { "🥳 vscode-cli has been installed.", "", "👷 Running /tmp/vscode-cli/bin/code serve-web --port 13338 --without-connection-token --accept-server-license-terms in the background...", - "Check logs at /tmp/vscode-web.log!" + "Check logs at /tmp/vscode-web.log!", ]); }); - });