test: allow env override

pull/222/head
Michael Brewer 1 year ago
parent d363ab3aa4
commit 074f6ab956
No known key found for this signature in database
GPG Key ID: D7A137BA1254AFC7

@ -44,4 +44,26 @@ describe("git-config", async () => {
{ type: "coder_env", name: "git_commmiter_name" }, { type: "coder_env", name: "git_commmiter_name" },
]); ]);
}); });
it("can run apply allow_email_change enabled", async () => {
const state = await runTerraformApply(
import.meta.dir,
{
agent_id: "foo",
allow_username_change: "false",
allow_email_change: "false",
},
{ CODER_WORKSPACE_OWNER_EMAIL: "foo@emai.com" },
);
const resources = state.resources;
expect(resources).toHaveLength(5);
expect(resources).toMatchObject([
{ type: "coder_workspace", name: "me" },
{ type: "coder_env", name: "git_author_email" },
{ type: "coder_env", name: "git_author_name" },
{ type: "coder_env", name: "git_commmiter_email" },
{ type: "coder_env", name: "git_commmiter_name" },
]);
});
}); });

@ -171,9 +171,9 @@ export const testRequiredVariables = (
export const runTerraformApply = async ( export const runTerraformApply = async (
dir: string, dir: string,
vars: Record<string, string>, vars: Record<string, string>,
env: Record<string, string> = {},
): Promise<TerraformState> => { ): Promise<TerraformState> => {
const stateFile = `${dir}/${crypto.randomUUID()}.tfstate`; const stateFile = `${dir}/${crypto.randomUUID()}.tfstate`;
const env = {};
Object.keys(vars).forEach((key) => (env[`TF_VAR_${key}`] = vars[key])); Object.keys(vars).forEach((key) => (env[`TF_VAR_${key}`] = vars[key]));
const proc = spawn( const proc = spawn(
[ [

Loading…
Cancel
Save