Skip to content

Commit 7df0ead

Browse files
committed
Add unit test for display name changing
1 parent d350d0c commit 7df0ead

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

enterprise/coderd/groups_test.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,37 @@ func TestPatchGroup(t *testing.T) {
149149
require.Equal(t, 20, group.QuotaAllowance)
150150
})
151151

152+
t.Run("DisplayNameUnchanged", func(t *testing.T) {
153+
t.Parallel()
154+
155+
client, user := coderdenttest.New(t, &coderdenttest.Options{LicenseOptions: &coderdenttest.LicenseOptions{
156+
Features: license.Features{
157+
codersdk.FeatureTemplateRBAC: 1,
158+
},
159+
}})
160+
const displayName = "foobar"
161+
ctx := testutil.Context(t, testutil.WaitLong)
162+
group, err := client.CreateGroup(ctx, user.OrganizationID, codersdk.CreateGroupRequest{
163+
Name: "hi",
164+
AvatarURL: "https://example.com",
165+
QuotaAllowance: 10,
166+
DisplayName: displayName,
167+
})
168+
require.NoError(t, err)
169+
require.Equal(t, 10, group.QuotaAllowance)
170+
171+
group, err = client.PatchGroup(ctx, group.ID, codersdk.PatchGroupRequest{
172+
Name: "bye",
173+
AvatarURL: ptr.Ref("https://google.com"),
174+
QuotaAllowance: ptr.Ref(20),
175+
})
176+
require.NoError(t, err)
177+
require.Equal(t, displayName, group.DisplayName)
178+
require.Equal(t, "bye", group.Name)
179+
require.Equal(t, "https://google.com", group.AvatarURL)
180+
require.Equal(t, 20, group.QuotaAllowance)
181+
})
182+
152183
// The FE sends a request from the edit page where the old name == new name.
153184
// This should pass since it's not really an error to update a group name
154185
// to itself.

0 commit comments

Comments
 (0)