From b35dec9f8c8d97d92a19777489015dd731bb37ba Mon Sep 17 00:00:00 2001 From: Ethan Dickson Date: Wed, 17 Jul 2024 07:53:39 +0000 Subject: [PATCH] chore: add groups to integration test --- integration/integration_test.go | 20 +++++++++++++++++++- integration/user-test/main.tf | 23 +++++++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/integration/integration_test.go b/integration/integration_test.go index f9774c2..abcd8f2 100644 --- a/integration/integration_test.go +++ b/integration/integration_test.go @@ -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!", @@ -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. @@ -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) }, }, } { @@ -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) }) diff --git a/integration/user-test/main.tf b/integration/user-test/main.tf index 83bd655..48ffffb 100644 --- a/integration/user-test/main.tf +++ b/integration/user-test/main.tf @@ -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 +} + +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 +} 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