Skip to content

Commit

Permalink
chore: add groups to integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanndickson committed Jul 19, 2024
1 parent 63f4357 commit 8222503
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
14 changes: 14 additions & 0 deletions integration/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ func TestIntegration(t *testing.T) {
OrganizationID: me.OrganizationIDs[0],
})
assert.NoError(t, err)
_, err = c.CreateGroup(ctx, me.OrganizationIDs[0], codersdk.CreateGroupRequest{
Name: "bosses",
QuotaAllowance: 200,
})
assert.NoError(t, err)
},
assertF: func(t testing.TB, c *codersdk.Client) {
// Check user fields.
Expand Down Expand Up @@ -86,6 +91,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 +125,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
24 changes: 24 additions & 0 deletions integration/user-test/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,27 @@ resource "coderd_user" "ethan2" {
roles = data.coderd_user.ethan.roles
suspended = data.coderd_user.ethan.suspended
}

data "coderd_organization" "default" {
is_default = true
}

data "coderd_group" "ethans_group" {
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 = [
resource.coderd_user.dean.id,
data.coderd_user.ethan.id,
resource.coderd_user.ethan2.id,
]
}

data "coderd_group" "employees" {
id = resource.coderd_group.employees.id
}

0 comments on commit 8222503

Please sign in to comment.