|
| 1 | +import { describe, expect, it } from "bun:test"; |
| 2 | +import { |
| 3 | + runTerraformApply, |
| 4 | + runTerraformInit, |
| 5 | + testRequiredVariables, |
| 6 | +} from "../test"; |
| 7 | + |
| 8 | +describe("git-config", async () => { |
| 9 | + await runTerraformInit(import.meta.dir); |
| 10 | + |
| 11 | + testRequiredVariables(import.meta.dir, { |
| 12 | + agent_id: "foo", |
| 13 | + }); |
| 14 | + |
| 15 | + it("can run apply allow_username_change and allow_email_change disabled", async () => { |
| 16 | + const state = await runTerraformApply(import.meta.dir, { |
| 17 | + agent_id: "foo", |
| 18 | + allow_username_change: "false", |
| 19 | + allow_email_change: "false", |
| 20 | + }); |
| 21 | + |
| 22 | + const resources = state.resources; |
| 23 | + expect(resources).toHaveLength(3); |
| 24 | + expect(resources).toMatchObject([ |
| 25 | + { type: "coder_workspace", name: "me" }, |
| 26 | + { type: "coder_env", name: "git_author_name" }, |
| 27 | + { type: "coder_env", name: "git_commmiter_name" }, |
| 28 | + ]); |
| 29 | + }); |
| 30 | + |
| 31 | + it("can run apply allow_email_change enabled", async () => { |
| 32 | + const state = await runTerraformApply(import.meta.dir, { |
| 33 | + agent_id: "foo", |
| 34 | + allow_email_change: "true", |
| 35 | + }); |
| 36 | + |
| 37 | + const resources = state.resources; |
| 38 | + expect(resources).toHaveLength(5); |
| 39 | + expect(resources).toMatchObject([ |
| 40 | + { type: "coder_parameter", name: "user_email" }, |
| 41 | + { type: "coder_parameter", name: "username" }, |
| 42 | + { type: "coder_workspace", name: "me" }, |
| 43 | + { type: "coder_env", name: "git_author_name" }, |
| 44 | + { type: "coder_env", name: "git_commmiter_name" }, |
| 45 | + ]); |
| 46 | + }); |
| 47 | + |
| 48 | + it("can run apply allow_email_change enabled", async () => { |
| 49 | + const state = await runTerraformApply( |
| 50 | + import.meta.dir, |
| 51 | + { |
| 52 | + agent_id: "foo", |
| 53 | + allow_username_change: "false", |
| 54 | + allow_email_change: "false", |
| 55 | + }, |
| 56 | + { CODER_WORKSPACE_OWNER_EMAIL: "foo@emai.com" }, |
| 57 | + ); |
| 58 | + |
| 59 | + const resources = state.resources; |
| 60 | + expect(resources).toHaveLength(5); |
| 61 | + expect(resources).toMatchObject([ |
| 62 | + { type: "coder_workspace", name: "me" }, |
| 63 | + { type: "coder_env", name: "git_author_email" }, |
| 64 | + { type: "coder_env", name: "git_author_name" }, |
| 65 | + { type: "coder_env", name: "git_commmiter_email" }, |
| 66 | + { type: "coder_env", name: "git_commmiter_name" }, |
| 67 | + ]); |
| 68 | + }); |
| 69 | +}); |
0 commit comments