|
| 1 | +import { describe, expect, it } from "bun:test"; |
| 2 | +import { |
| 3 | + executeScriptInContainer, |
| 4 | + runTerraformApply, |
| 5 | + runTerraformInit, |
| 6 | +} from "../test"; |
| 7 | + |
| 8 | +describe("vscode-web", async () => { |
| 9 | + await runTerraformInit(import.meta.dir); |
| 10 | + |
| 11 | + |
| 12 | + // replaces testRequiredVariables due to license var |
| 13 | + it("missing agent_id", async () => { |
| 14 | + try { |
| 15 | + await runTerraformApply(import.meta.dir, { |
| 16 | + accept_license: "true", |
| 17 | + }); |
| 18 | + } catch (ex) { |
| 19 | + expect(ex.message).toContain( |
| 20 | + 'input variable "agent_id" is not set' |
| 21 | + ); |
| 22 | + } |
| 23 | + }); |
| 24 | + |
| 25 | + it("invalid license_agreement", async () => { |
| 26 | + |
| 27 | + try { |
| 28 | + await runTerraformApply(import.meta.dir, { |
| 29 | + agent_id: "foo", |
| 30 | + }); |
| 31 | + } catch (ex) { |
| 32 | + expect(ex.message).toContain( |
| 33 | + 'You must accept the VS Code license agreement by setting accept_license=true' |
| 34 | + ); |
| 35 | + } |
| 36 | + }); |
| 37 | + |
| 38 | + it("fails without curl", async () => { |
| 39 | + const state = await runTerraformApply(import.meta.dir, { |
| 40 | + agent_id: "foo", |
| 41 | + accept_license: "true", |
| 42 | + }); |
| 43 | + const output = await executeScriptInContainer(state, "alpine"); |
| 44 | + expect(output.exitCode).toBe(1); |
| 45 | + expect(output.stdout).toEqual([ |
| 46 | + "\u001b[0;1mInstalling vscode-cli!", |
| 47 | + "Failed to install vscode-cli:", // TODO: manually test error log |
| 48 | + ]); |
| 49 | + }); |
| 50 | + |
| 51 | + it("runs with curl", async () => { |
| 52 | + const state = await runTerraformApply(import.meta.dir, { |
| 53 | + agent_id: "foo", |
| 54 | + accept_license: "true", |
| 55 | + }); |
| 56 | + const output = await executeScriptInContainer(state, "alpine/curl"); |
| 57 | + expect(output.exitCode).toBe(0); |
| 58 | + expect(output.stdout).toEqual([ |
| 59 | + "\u001b[0;1mInstalling vscode-cli!", |
| 60 | + "🥳 vscode-cli has been installed.", |
| 61 | + "", |
| 62 | + "👷 Running /tmp/vscode-cli/bin/code serve-web --port 13338 --without-connection-token --accept-server-license-terms in the background...", |
| 63 | + "Check logs at /tmp/vscode-web.log!" |
| 64 | + ]); |
| 65 | + }); |
| 66 | + |
| 67 | +}); |
0 commit comments