fix: make sure TF tests run properly

This commit is contained in:
Michael Smith 2025-04-16 22:25:06 +00:00
parent 8480748023
commit c3822eafe5

View File

@ -202,6 +202,14 @@ export const runTerraformApply = async <TVars extends TerraformVariables>(
...process.env,
...(customEnv ?? {}),
};
// This is a fix for when you try to run the tests from a Coder workspace.
// When process.env is destructured into the object, it can sometimes have
// workspace-specific values, which causes the resulting URL to be different
// from what the tests have classically expected.
childEnv.CODER_AGENT_URL = undefined;
childEnv.CODER_WORKSPACE_NAME = undefined;
for (const [key, value] of Object.entries(vars) as [string, JsonValue][]) {
if (value !== null) {
childEnv[`TF_VAR_${key}`] = String(value);