Skip to content

Commit 476ed7d

Browse files
committed
add unit test to verify not deleting org member from default org
1 parent 419cb44 commit 476ed7d

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

coderd/members_test.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,25 @@ func TestAddMember(t *testing.T) {
3030
})
3131
}
3232

33+
func TestDeleteMember(t *testing.T) {
34+
t.Parallel()
35+
36+
t.Run("NotAllowed", func(t *testing.T) {
37+
t.Parallel()
38+
owner := coderdtest.New(t, nil)
39+
first := coderdtest.CreateFirstUser(t, owner)
40+
_, user := coderdtest.CreateAnotherUser(t, owner, first.OrganizationID)
41+
42+
ctx := testutil.Context(t, testutil.WaitMedium)
43+
// Deleting members from the default org is not allowed.
44+
// If this behavior changes, and we allow deleting members from the default org,
45+
// this test should be updated to check there is no error.
46+
// nolint:gocritic // must be an owner to see the user
47+
err := owner.DeleteOrganizationMember(ctx, first.OrganizationID, user.Username)
48+
require.ErrorContains(t, err, "Multi-organizations is currently an experiment")
49+
})
50+
}
51+
3352
func TestListMembers(t *testing.T) {
3453
t.Parallel()
3554

0 commit comments

Comments
 (0)