Skip to content

Commit

Permalink
Refactor redundant append operations in test setup (#5211)
Browse files Browse the repository at this point in the history
* Refactor redundant append operations in test setup

- Simplified code by removing unnecessary if-else conditions in the wantUserIds and wantGroupIds blocks.

Fixes #5205

* chore: fmt fix
  • Loading branch information
bgajjala8 authored Dec 3, 2024
1 parent ae0ca0c commit 58cc322
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions internal/iam/repository_principal_role_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,20 +141,12 @@ func TestRepository_AddPrincipalRoles(t *testing.T) {
if tt.args.wantUserIds {
userIds = createUsersFn(orgs)
u := TestUser(t, repo, staticOrg.PublicId)
if roleId == orgRole.PublicId {
userIds = append(userIds, u.PublicId)
} else {
userIds = append(userIds, u.PublicId)
}
userIds = append(userIds, u.PublicId)
}
if tt.args.wantGroupIds {
groupIds = createGrpsFn(orgs, projects)
g := TestGroup(t, conn, staticProj.PublicId)
if roleId == projRole.PublicId {
groupIds = append(groupIds, g.PublicId)
} else {
groupIds = append(groupIds, g.PublicId)
}
groupIds = append(groupIds, g.PublicId)
}
if len(tt.args.specificUserIds) > 0 {
userIds = tt.args.specificUserIds
Expand Down

0 comments on commit 58cc322

Please sign in to comment.