MCPcopy Index your code
hub / github.com/coder/coder / TestGetGroupMembersPagination

Function TestGetGroupMembersPagination

enterprise/coderd/groups_test.go:1199–1236  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1197}
1198
1199func TestGetGroupMembersPagination(t *testing.T) {
1200 t.Parallel()
1201
1202 client, first := coderdenttest.New(t, &coderdenttest.Options{
1203 LicenseOptions: &coderdenttest.LicenseOptions{
1204 Features: license.Features{
1205 codersdk.FeatureTemplateRBAC: 1,
1206 },
1207 },
1208 })
1209
1210 userAdminClient, _ := coderdtest.CreateAnotherUser(t, client, first.OrganizationID, rbac.RoleUserAdmin())
1211
1212 ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong)
1213 t.Cleanup(cancel)
1214
1215 group, err := userAdminClient.CreateGroup(ctx, first.OrganizationID, codersdk.CreateGroupRequest{
1216 Name: "paginated",
1217 })
1218 require.NoError(t, err)
1219
1220 setup := func(users []codersdk.User) {
1221 userIDs := make([]string, len(users))
1222 for i, user := range users {
1223 userIDs[i] = user.ID.String()
1224 }
1225 group, err = userAdminClient.PatchGroup(ctx, group.ID, codersdk.PatchGroupRequest{
1226 AddUsers: userIDs,
1227 })
1228 require.NoError(t, err)
1229 }
1230 fetch := func(req codersdk.UsersRequest) ([]codersdk.ReducedUser, int) {
1231 group, err := userAdminClient.GroupMembers(ctx, group.ID, req)
1232 require.NoError(t, err)
1233 return group.Users, group.Count
1234 }
1235 coderdtest.UsersPagination(ctx, t, client, setup, fetch)
1236}

Callers

nothing calls this directly

Calls 9

NewFunction · 0.92
CreateAnotherUserFunction · 0.92
RoleUserAdminFunction · 0.92
UsersPaginationFunction · 0.92
CreateGroupMethod · 0.80
PatchGroupMethod · 0.80
GroupMembersMethod · 0.80
CleanupMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected