Compare commits
3 Commits
main
...
fix/vscode
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
47dd64a40b | ||
|
|
86045b5a64 | ||
|
|
4669c0e48c |
@ -1,5 +1,13 @@
|
||||
import { describe, expect, it } from "bun:test";
|
||||
import { runTerraformApply, runTerraformInit } from "~test";
|
||||
import {
|
||||
execContainer,
|
||||
findResourceInstance,
|
||||
readFileContainer,
|
||||
removeContainer,
|
||||
runContainer,
|
||||
runTerraformApply,
|
||||
runTerraformInit,
|
||||
} from "~test";
|
||||
|
||||
describe("vscode-web", async () => {
|
||||
await runTerraformInit(import.meta.dir);
|
||||
@ -38,5 +46,52 @@ describe("vscode-web", async () => {
|
||||
expect(t).toThrow("Offline mode does not allow extensions to be installed");
|
||||
});
|
||||
|
||||
// More tests depend on shebang refactors
|
||||
it("writes settings to User settings path not Machine", async () => {
|
||||
const state = await runTerraformApply(import.meta.dir, {
|
||||
agent_id: "foo",
|
||||
accept_license: "true",
|
||||
offline: "true",
|
||||
});
|
||||
const instance = findResourceInstance(state, "coder_script");
|
||||
// Verify the script uses User path, not Machine path
|
||||
expect(instance.script).toContain(".vscode-server/data/User/settings.json");
|
||||
expect(instance.script).not.toContain(
|
||||
".vscode-server/data/Machine/settings.json",
|
||||
);
|
||||
});
|
||||
|
||||
it("writes provided settings to ~/.vscode-server/data/User/settings.json", async () => {
|
||||
const id = await runContainer("alpine");
|
||||
try {
|
||||
const settings = {
|
||||
"editor.fontSize": 16,
|
||||
"workbench.colorTheme": "Default Dark+",
|
||||
};
|
||||
const state = await runTerraformApply(import.meta.dir, {
|
||||
agent_id: "foo",
|
||||
accept_license: "true",
|
||||
offline: "true",
|
||||
settings: JSON.stringify(settings),
|
||||
});
|
||||
const instance = findResourceInstance(state, "coder_script");
|
||||
// Extract and run only the settings portion of the script
|
||||
const settingsScript = `
|
||||
SETTINGS='${JSON.stringify(settings).replace(/'/g, "'\\''")}'
|
||||
if [ ! -f ~/.vscode-server/data/User/settings.json ]; then
|
||||
mkdir -p ~/.vscode-server/data/User
|
||||
echo "$SETTINGS" > ~/.vscode-server/data/User/settings.json
|
||||
fi
|
||||
`;
|
||||
const resp = await execContainer(id, ["sh", "-c", settingsScript]);
|
||||
expect(resp.exitCode).toBe(0);
|
||||
const content = await readFileContainer(
|
||||
id,
|
||||
"/root/.vscode-server/data/User/settings.json",
|
||||
);
|
||||
const actualSettings = JSON.parse(content.trim());
|
||||
expect(actualSettings).toEqual(settings);
|
||||
} finally {
|
||||
await removeContainer(id);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@ -29,10 +29,10 @@ run_vscode_web() {
|
||||
}
|
||||
|
||||
# Check if the settings file exists...
|
||||
if [ ! -f ~/.vscode-server/data/Machine/settings.json ]; then
|
||||
if [ ! -f ~/.vscode-server/data/User/settings.json ]; then
|
||||
echo "⚙️ Creating settings file..."
|
||||
mkdir -p ~/.vscode-server/data/Machine
|
||||
echo "${SETTINGS}" > ~/.vscode-server/data/Machine/settings.json
|
||||
mkdir -p ~/.vscode-server/data/User
|
||||
echo "${SETTINGS}" > ~/.vscode-server/data/User/settings.json
|
||||
fi
|
||||
|
||||
# Check if vscode-server is already installed for offline or cached mode
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user