Skip to content

Commit

Permalink
fix(git-config): add support for coder 0.22 (#254)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelbrewer authored May 28, 2024
1 parent beaa33b commit c6b457e
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 9 deletions.
39 changes: 31 additions & 8 deletions git-config/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@ describe("git-config", async () => {
});

const resources = state.resources;
expect(resources).toHaveLength(3);
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" },
]);
});
Expand All @@ -35,12 +37,14 @@ describe("git-config", async () => {
});

const resources = state.resources;
expect(resources).toHaveLength(5);
expect(resources).toHaveLength(7);
expect(resources).toMatchObject([
{ type: "coder_parameter", name: "user_email" },
{ type: "coder_parameter", name: "username" },
{ 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" },
]);
});
Expand All @@ -53,7 +57,7 @@ describe("git-config", async () => {
allow_username_change: "false",
allow_email_change: "false",
},
{ CODER_WORKSPACE_OWNER_EMAIL: "foo@emai.com" },
{ CODER_WORKSPACE_OWNER_EMAIL: "foo@email.com" },
);

const resources = state.resources;
Expand All @@ -75,12 +79,22 @@ describe("git-config", async () => {
allow_email_change: "true",
coder_parameter_order: order.toString(),
});
expect(state.resources).toHaveLength(5);
const resources = state.resources;
expect(resources).toHaveLength(7);
expect(resources).toMatchObject([
{ type: "coder_parameter", name: "user_email" },
{ type: "coder_parameter", name: "username" },
{ 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" },
]);
// user_email order is the same as the order
expect(state.resources[0].instances[0].attributes.order).toBe(order);
expect(resources[0].instances[0].attributes.order).toBe(order);
// username order is incremented by 1
// @ts-ignore: Object is possibly 'null'.
expect(state.resources[1].instances[0]?.attributes.order).toBe(order + 1);
expect(resources[1].instances[0]?.attributes.order).toBe(order + 1);
});

it("set custom order for coder_parameter for just username", async () => {
Expand All @@ -91,9 +105,18 @@ describe("git-config", async () => {
allow_username_change: "true",
coder_parameter_order: order.toString(),
});
expect(state.resources).toHaveLength(4);
const resources = state.resources;
expect(resources).toHaveLength(6);
expect(resources).toMatchObject([
{ type: "coder_parameter", name: "username" },
{ 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" },
]);
// user_email was not created
// username order is incremented by 1
expect(state.resources[0].instances[0].attributes.order).toBe(order + 1);
expect(resources[0].instances[0].attributes.order).toBe(order + 1);
});
});
2 changes: 1 addition & 1 deletion git-config/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ terraform {
required_providers {
coder = {
source = "coder/coder"
version = ">= 0.13"
version = ">= 0.22"
}
}
}
Expand Down

0 comments on commit c6b457e

Please sign in to comment.