Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion integration/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func TestIntegration(t *testing.T) {
preF: func(t testing.TB, c *codersdk.Client) {
me, err := c.User(ctx, codersdk.Me)
assert.NoError(t, err)
_, err = c.CreateUser(ctx, codersdk.CreateUserRequest{
user1, err := c.CreateUser(ctx, codersdk.CreateUserRequest{
Email: "test2@coder.com",
Username: "ethan",
Password: "SomeSecurePassword!",
Expand All @@ -59,6 +59,15 @@ func TestIntegration(t *testing.T) {
OrganizationID: me.OrganizationIDs[0],
})
assert.NoError(t, err)
group, err := c.CreateGroup(ctx, me.OrganizationIDs[0], codersdk.CreateGroupRequest{
Name: "bosses",
QuotaAllowance: 200,
})
assert.NoError(t, err)
_, err = c.PatchGroup(ctx, group.ID, codersdk.PatchGroupRequest{
AddUsers: []string{user1.ID.String()},
})
assert.NoError(t, err)
},
assertF: func(t testing.TB, c *codersdk.Client) {
// Check user fields.
Expand Down Expand Up @@ -86,6 +95,14 @@ func TestIntegration(t *testing.T) {
user, err = newClient.User(ctx, codersdk.Me)
assert.NoError(t, err)
assert.Equal(t, "dean", user.Username)

// Check group
defaultOrg, err := c.OrganizationByName(ctx, "first-organization")
assert.NoError(t, err)
group, err := c.GroupByOrgAndName(ctx, defaultOrg.ID, "employees")
assert.NoError(t, err)
assert.Len(t, group.Members, 3)
assert.Equal(t, group.QuotaAllowance, 100)
},
},
} {
Expand All @@ -112,6 +129,7 @@ func TestIntegration(t *testing.T) {
tt.preF(t, client)
if err := tfCmd.Run(); !assert.NoError(t, err) {
t.Logf(buf.String())
t.FailNow()
}
tt.assertF(t, client)
})
Expand Down
23 changes: 23 additions & 0 deletions integration/user-test/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,26 @@ resource "coderd_user" "ethan2" {
roles = data.coderd_user.ethan.roles
suspended = data.coderd_user.ethan.suspended
}

data "coderd_organization" "default" {
is_default = true
}
Copy link
Member Author

@ethanndickson ethanndickson Jul 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not totally sure on this from a UX perspective - but we can't use name="default" because the first organisation, whilst it can be retrieved using the name default, actually has the name first-organization.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and I'm 90% sure Terraform is always going to spit the dummy if we just replaced the given name?


data "coderd_group" "bosses" {
name = "bosses"
organization_id = data.coderd_organization.default.id
}

resource "coderd_group" "employees" {
name = "employees"
organization_id = data.coderd_organization.default.id
quota_allowance = 100
members = concat([
resource.coderd_user.dean.id,
resource.coderd_user.ethan2.id,
], data.coderd_group.bosses.members[*].id)
}

data "coderd_group" "employees" {
id = resource.coderd_group.employees.id
}
Loading
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy