added tests for vscode-web
This commit is contained in:
@@ -12,4 +12,10 @@ describe("dotfiles", async () => {
|
||||
agent_id: "foo",
|
||||
});
|
||||
|
||||
it("default output", async () => {
|
||||
const state = await runTerraformApply(import.meta.dir, {
|
||||
agent_id: "foo",
|
||||
});
|
||||
expect(state.outputs.dotfiles_uri.value).toBe("");
|
||||
});
|
||||
});
|
||||
|
||||
2
test.ts
2
test.ts
@@ -129,7 +129,7 @@ export const findResourceInstance = <T extends "coder_script" | string>(
|
||||
return resource.instances[0].attributes as any;
|
||||
};
|
||||
|
||||
// assertRequiredVariables creates a test-case
|
||||
// testRequiredVariables creates a test-case
|
||||
// for each variable provided and ensures that
|
||||
// the apply fails without it.
|
||||
export const testRequiredVariables = (
|
||||
|
||||
67
vscode-web/main.test.ts
Normal file
67
vscode-web/main.test.ts
Normal file
@@ -0,0 +1,67 @@
|
||||
import { describe, expect, it } from "bun:test";
|
||||
import {
|
||||
executeScriptInContainer,
|
||||
runTerraformApply,
|
||||
runTerraformInit,
|
||||
} from "../test";
|
||||
|
||||
describe("vscode-web", async () => {
|
||||
await runTerraformInit(import.meta.dir);
|
||||
|
||||
|
||||
// replaces testRequiredVariables due to license var
|
||||
it("missing agent_id", async () => {
|
||||
try {
|
||||
await runTerraformApply(import.meta.dir, {
|
||||
accept_license: "true",
|
||||
});
|
||||
} catch (ex) {
|
||||
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'
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
it("fails without curl", async () => {
|
||||
const state = await runTerraformApply(import.meta.dir, {
|
||||
agent_id: "foo",
|
||||
accept_license: "true",
|
||||
});
|
||||
const output = await executeScriptInContainer(state, "alpine");
|
||||
expect(output.exitCode).toBe(1);
|
||||
expect(output.stdout).toEqual([
|
||||
"\u001b[0;1mInstalling vscode-cli!",
|
||||
"Failed to install vscode-cli:", // TODO: manually test error log
|
||||
]);
|
||||
});
|
||||
|
||||
it("runs with curl", async () => {
|
||||
const state = await runTerraformApply(import.meta.dir, {
|
||||
agent_id: "foo",
|
||||
accept_license: "true",
|
||||
});
|
||||
const output = await executeScriptInContainer(state, "alpine/curl");
|
||||
expect(output.exitCode).toBe(0);
|
||||
expect(output.stdout).toEqual([
|
||||
"\u001b[0;1mInstalling vscode-cli!",
|
||||
"🥳 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!"
|
||||
]);
|
||||
});
|
||||
|
||||
});
|
||||
Reference in New Issue
Block a user