Archived
1
0

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>
This commit is contained in:
Joe Previte 2022-08-09 15:41:37 -05:00 committed by GitHub
parent a51c94190f
commit 11b2ef9846
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 2 deletions

View File

@ -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")
})
})

View File

@ -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 }
}