From 7c8698b319d144179d49dc1880f89ea38e8a8a0b Mon Sep 17 00:00:00 2001 From: Joe Previte Date: Tue, 9 Aug 2022 11:52:19 -0700 Subject: [PATCH 1/2] refactor: add env arg to runCodeServerCommand This allows yous to pass environment variables to code-server's helper when running integration tests. --- test/utils/runCodeServerCommand.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/test/utils/runCodeServerCommand.ts b/test/utils/runCodeServerCommand.ts index cb1e45638bd7..bd526e85a80c 100644 --- a/test/utils/runCodeServerCommand.ts +++ b/test/utils/runCodeServerCommand.ts @@ -6,9 +6,14 @@ import { promisify } from "util" * * A helper function for integration tests to run code-server commands. */ -export async function runCodeServerCommand(argv: string[]): Promise<{ stdout: string; stderr: string }> { +export async function runCodeServerCommand( + argv: string[], + env?: NodeJS.ProcessEnv, +): Promise<{ stdout: string; stderr: string }> { const CODE_SERVER_COMMAND = process.env.CODE_SERVER_PATH || path.resolve("../../release-standalone/bin/code-server") - const { stdout, stderr } = await promisify(exec)(`${CODE_SERVER_COMMAND} ${argv.join(" ")}`) + const { stdout, stderr } = await promisify(exec)(`${CODE_SERVER_COMMAND} ${argv.join(" ")}`, { + env: { ...process.env, ...env }, + }) return { stdout, stderr } } From 10b47fd3a5e2cbb352894eadc4304fd30e2643f2 Mon Sep 17 00:00:00 2001 From: Joe Previte Date: Tue, 9 Aug 2022 11:53:14 -0700 Subject: [PATCH 2/2] feat: add EXTENSIONS_GALLERY integration test This test ensures EXTENSIONS_GALLERY is read when set and using the `--install-extension` flag. --- test/integration/installExtension.test.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/integration/installExtension.test.ts b/test/integration/installExtension.test.ts index d22cee802a7b..ad4756f8a8d6 100644 --- a/test/integration/installExtension.test.ts +++ b/test/integration/installExtension.test.ts @@ -22,4 +22,11 @@ describe("--install-extension", () => { const statInfo = await stat(pathToExtFolder) expect(statInfo.isDirectory()).toBe(true) }, 20000) + it("should use EXTENSIONS_GALLERY when set", async () => { + const extName = `author.extension-1.0.0` + const { stderr } = await runCodeServerCommand([...setupFlags, "--install-extension", extName], { + EXTENSIONS_GALLERY: "{}", + }) + expect(stderr).toMatch("No extension gallery service configured") + }) })