Skip to content

Commit a83cd5b

Browse files
committed
added small test for jupyterlab
1 parent 698d816 commit a83cd5b

File tree

5 files changed

+63
-14
lines changed

5 files changed

+63
-14
lines changed

fly-region/main.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ describe("fly-region", async () => {
2525
it("region filter", async () => {
2626
const state = await runTerraformApply(import.meta.dir, {
2727
default: "atl",
28-
regions: '["arn", "ams", "bos"]'
28+
regions: '["arn", "ams", "bos"]',
2929
});
3030
expect(state.outputs.value.value).toBe("");
3131
});

jupyterlab/main.test.ts

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import { describe, expect, it } from "bun:test";
2+
import {
3+
executeScriptInContainer,
4+
runTerraformApply,
5+
runTerraformInit,
6+
testRequiredVariables,
7+
findResourceInstance,
8+
runContainer,
9+
} from "../test";
10+
11+
const executeScriptInContainer = async (
12+
state: TerraformState,
13+
image: string,
14+
shell: string = "sh",
15+
): Promise<{
16+
exitCode: number;
17+
stdout: string[];
18+
stderr: string[];
19+
}> => {
20+
const instance = findResourceInstance(state, "coder_script");
21+
const id = await runContainer(image);
22+
const resp = await execContainer(id, [shell, "-c", instance.script]);
23+
const stdout = resp.stdout.trim().split("\n");
24+
const stderr = resp.stderr.trim().split("\n");
25+
return {
26+
exitCode: resp.exitCode,
27+
stdout,
28+
stderr,
29+
};
30+
};
31+
32+
describe("jupyterlab", async () => {
33+
await runTerraformInit(import.meta.dir);
34+
35+
testRequiredVariables(import.meta.dir, {
36+
agent_id: "foo",
37+
});
38+
39+
it("fails without pip3", async () => {
40+
const state = await runTerraformApply(import.meta.dir, {
41+
agent_id: "foo",
42+
});
43+
44+
const instance = findResourceInstance(state, "coder_script");
45+
const id = await runContainer("alpine");
46+
const output = await executeScriptInContainer(state, "alpine");
47+
expect(output.exitCode).toBe(1);
48+
expect(output.stdout).toEqual([
49+
"\u001B[0;1mInstalling jupyterlab!",
50+
"pip3 is not installed",
51+
"Please install pip3 in your Dockerfile/VM image before running this script",
52+
]);
53+
});
54+
55+
// TODO: Add test that runs with pip
56+
// May be best to use dockerfile
57+
});

vscode-desktop/main.test.ts

+1-4
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,12 @@ describe("vscode-desktop", async () => {
1313
agent_id: "foo",
1414
});
1515

16-
1716
it("default output", async () => {
1817
const state = await runTerraformApply(import.meta.dir, {
1918
agent_id: "foo",
2019
});
2120
expect(state.outputs.vscode_url.value).toBe(
22-
"vscode://coder.coder-remote/open?owner=default&workspace=default&token=$SESSION_TOKEN"
21+
"vscode://coder.coder-remote/open?owner=default&workspace=default&token=$SESSION_TOKEN",
2322
);
2423
});
25-
26-
2724
});

vscode-desktop/main.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,6 @@ resource "coder_app" "vscode" {
4646
}
4747

4848
output "vscode_url" {
49-
value = coder_app.vscode.url
49+
value = coder_app.vscode.url
5050
description = "VS Code Desktop URL."
5151
}

vscode-web/main.test.ts

+3-8
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import {
88
describe("vscode-web", async () => {
99
await runTerraformInit(import.meta.dir);
1010

11-
1211
// replaces testRequiredVariables due to license variable
1312
// may add a testRequiredVariablesWithLicense function later
1413
it("missing agent_id", async () => {
@@ -17,21 +16,18 @@ describe("vscode-web", async () => {
1716
accept_license: "true",
1817
});
1918
} catch (ex) {
20-
expect(ex.message).toContain(
21-
'input variable "agent_id" is not set'
22-
);
19+
expect(ex.message).toContain('input variable "agent_id" is not set');
2320
}
2421
});
2522

2623
it("invalid license_agreement", async () => {
27-
2824
try {
2925
await runTerraformApply(import.meta.dir, {
3026
agent_id: "foo",
3127
});
3228
} catch (ex) {
3329
expect(ex.message).toContain(
34-
'You must accept the VS Code license agreement by setting accept_license=true'
30+
"You must accept the VS Code license agreement by setting accept_license=true",
3531
);
3632
}
3733
});
@@ -61,8 +57,7 @@ describe("vscode-web", async () => {
6157
"🥳 vscode-cli has been installed.",
6258
"",
6359
"👷 Running /tmp/vscode-cli/bin/code serve-web --port 13338 --without-connection-token --accept-server-license-terms in the background...",
64-
"Check logs at /tmp/vscode-web.log!"
60+
"Check logs at /tmp/vscode-web.log!",
6561
]);
6662
});
67-
6863
});

0 commit comments

Comments
 (0)