Skip to content

Commit 39670c5

Browse files
committed
chore: add groups to integration test
1 parent adb48de commit 39670c5

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

integration/integration_test.go

+14
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ func TestIntegration(t *testing.T) {
5959
OrganizationID: me.OrganizationIDs[0],
6060
})
6161
assert.NoError(t, err)
62+
_, err = c.CreateGroup(ctx, me.OrganizationIDs[0], codersdk.CreateGroupRequest{
63+
Name: "bosses",
64+
QuotaAllowance: 200,
65+
})
66+
assert.NoError(t, err)
6267
},
6368
assertF: func(t testing.TB, c *codersdk.Client) {
6469
// Check user fields.
@@ -86,6 +91,14 @@ func TestIntegration(t *testing.T) {
8691
user, err = newClient.User(ctx, codersdk.Me)
8792
assert.NoError(t, err)
8893
assert.Equal(t, "dean", user.Username)
94+
95+
// Check group
96+
defaultOrg, err := c.OrganizationByName(ctx, "first-organization")
97+
assert.NoError(t, err)
98+
group, err := c.GroupByOrgAndName(ctx, defaultOrg.ID, "employees")
99+
assert.NoError(t, err)
100+
assert.Len(t, group.Members, 3)
101+
assert.Equal(t, group.QuotaAllowance, 100)
89102
},
90103
},
91104
} {
@@ -112,6 +125,7 @@ func TestIntegration(t *testing.T) {
112125
tt.preF(t, client)
113126
if err := tfCmd.Run(); !assert.NoError(t, err) {
114127
t.Logf(buf.String())
128+
t.FailNow()
115129
}
116130
tt.assertF(t, client)
117131
})

integration/user-test/main.tf

+24
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,27 @@ resource "coderd_user" "ethan2" {
2828
roles = data.coderd_user.ethan.roles
2929
suspended = data.coderd_user.ethan.suspended
3030
}
31+
32+
data "coderd_organization" "default" {
33+
is_default = true
34+
}
35+
36+
data "coderd_group" "ethans_group" {
37+
name = "bosses"
38+
organization_id = data.coderd_organization.default.id
39+
}
40+
41+
resource "coderd_group" "employees" {
42+
name = "employees"
43+
organization_id = data.coderd_organization.default.id
44+
quota_allowance = 100
45+
members = [
46+
resource.coderd_user.dean.id,
47+
data.coderd_user.ethan.id,
48+
resource.coderd_user.ethan2.id,
49+
]
50+
}
51+
52+
data "coderd_group" "employees" {
53+
id = resource.coderd_group.employees.id
54+
}

0 commit comments

Comments
 (0)