diff --git a/jetbrains-gateway/main.test.ts b/jetbrains-gateway/main.test.ts index 0a5b3bc3..d9df0efc 100644 --- a/jetbrains-gateway/main.test.ts +++ b/jetbrains-gateway/main.test.ts @@ -16,14 +16,13 @@ describe("jetbrains-gateway", async () => { it("should create a link with the default values", async () => { const state = await runTerraformApply(import.meta.dir, { - // These are all required. agent_id: "foo", agent_name: "foo", folder: "/home/coder", }); - expect(state.outputs.url.value).toBe( + expect(state.outputs.url.value).toEqual([ "jetbrains-gateway://connect#type=coder&workspace=default&owner=default&agent=foo&folder=/home/coder&url=https://mydeployment.coder.com&token=$SESSION_TOKEN&ide_product_code=IU&ide_build_number=241.14494.240&ide_download_link=https://download.jetbrains.com/idea/ideaIU-2024.1.tar.gz", - ); + ]); const coder_app = state.resources.find( (res) => res.type === "coder_app" && res.name === "gateway", @@ -34,13 +33,31 @@ describe("jetbrains-gateway", async () => { expect(coder_app?.instances[0].attributes.order).toBeNull(); }); - it("default to first ide", async () => { + it("default to first IDE", async () => { + const state = await runTerraformApply(import.meta.dir, { + agent_id: "foo", + agent_name: "foo", + folder: "/home/foo", + jetbrains_ides: ["IU", "PY"], + }); + expect(state.outputs.identifier.value).toEqual(["IU"]); + expect(state.outputs.url.value).toEqual([ + "jetbrains-gateway://connect#type=coder&workspace=default&owner=default&agent=foo&folder=/home/foo&url=https://mydeployment.coder.com&token=$SESSION_TOKEN&ide_product_code=IU&ide_build_number=241.14494.240&ide_download_link=https://download.jetbrains.com/idea/ideaIU-2024.1.tar.gz", + ]); + }); + + it("should create multiple IDEs", async () => { const state = await runTerraformApply(import.meta.dir, { agent_id: "foo", agent_name: "foo", folder: "/home/foo", - jetbrains_ides: '["IU", "GO", "PY"]', + default: ["GO", "IU", "PY"], }); - expect(state.outputs.identifier.value).toBe("IU"); + expect(state.outputs.identifier.value).toEqual(["GO", "IU", "PY"]); + expect(state.outputs.url.value).toEqual([ + "jetbrains-gateway://connect#type=coder&workspace=default&owner=default&agent=foo&folder=/home/foo&url=https://mydeployment.coder.com&token=$SESSION_TOKEN&ide_product_code=GO&ide_build_number=241.14494.238&ide_download_link=https://download.jetbrains.com/go/goland-2024.1.tar.gz", + "jetbrains-gateway://connect#type=coder&workspace=default&owner=default&agent=foo&folder=/home/foo&url=https://mydeployment.coder.com&token=$SESSION_TOKEN&ide_product_code=IU&ide_build_number=241.14494.240&ide_download_link=https://download.jetbrains.com/idea/ideaIU-2024.1.tar.gz", + "jetbrains-gateway://connect#type=coder&workspace=default&owner=default&agent=foo&folder=/home/foo&url=https://mydeployment.coder.com&token=$SESSION_TOKEN&ide_product_code=PY&ide_build_number=241.14494.241&ide_download_link=https://download.jetbrains.com/python/pycharm-professional-2024.1.tar.gz", + ]); }); }); diff --git a/test.ts b/test.ts index 5437374f..c6772535 100644 --- a/test.ts +++ b/test.ts @@ -200,7 +200,8 @@ export const runTerraformApply = async ( const combinedEnv = env === undefined ? {} : { ...env }; for (const [key, value] of Object.entries(vars)) { - combinedEnv[`TF_VAR_${key}`] = String(value); + // Convert arrays to JSON strings + combinedEnv[`TF_VAR_${key}`] = Array.isArray(value) ? JSON.stringify(value) : String(value); } const proc = spawn(