Skip to content

Commit 11b2ef9

Browse files
feat: add test for EXTENSIONS_GALLERY (#5432)
* refactor: add env arg to runCodeServerCommand This allows yous to pass environment variables to code-server's helper when running integration tests. * feat: add EXTENSIONS_GALLERY integration test This test ensures EXTENSIONS_GALLERY is read when set and using the `--install-extension` flag. Co-authored-by: repo-ranger[bot] <39074581+repo-ranger[bot]@users.noreply.github.com>
1 parent a51c941 commit 11b2ef9

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

test/integration/installExtension.test.ts

+7
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,11 @@ describe("--install-extension", () => {
2222
const statInfo = await stat(pathToExtFolder)
2323
expect(statInfo.isDirectory()).toBe(true)
2424
}, 20000)
25+
it("should use EXTENSIONS_GALLERY when set", async () => {
26+
const extName = `author.extension-1.0.0`
27+
const { stderr } = await runCodeServerCommand([...setupFlags, "--install-extension", extName], {
28+
EXTENSIONS_GALLERY: "{}",
29+
})
30+
expect(stderr).toMatch("No extension gallery service configured")
31+
})
2532
})

test/utils/runCodeServerCommand.ts

+7-2
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,14 @@ import { promisify } from "util"
66
*
77
* A helper function for integration tests to run code-server commands.
88
*/
9-
export async function runCodeServerCommand(argv: string[]): Promise<{ stdout: string; stderr: string }> {
9+
export async function runCodeServerCommand(
10+
argv: string[],
11+
env?: NodeJS.ProcessEnv,
12+
): Promise<{ stdout: string; stderr: string }> {
1013
const CODE_SERVER_COMMAND = process.env.CODE_SERVER_PATH || path.resolve("../../release-standalone/bin/code-server")
11-
const { stdout, stderr } = await promisify(exec)(`${CODE_SERVER_COMMAND} ${argv.join(" ")}`)
14+
const { stdout, stderr } = await promisify(exec)(`${CODE_SERVER_COMMAND} ${argv.join(" ")}`, {
15+
env: { ...process.env, ...env },
16+
})
1217

1318
return { stdout, stderr }
1419
}

0 commit comments

Comments
 (0)