Skip to content

Commit

Permalink
Fix creating org members when member list is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiught committed Jun 20, 2023
1 parent 3388f02 commit e8bf000
Show file tree
Hide file tree
Showing 3 changed files with 1,843 additions and 796 deletions.
2 changes: 1 addition & 1 deletion internal/auth0/organization/resource_members.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func createOrganizationMembers(ctx context.Context, data *schema.ResourceData, m
return diagnostics
}

if len(membersToAdd) > len(alreadyMembers.Members) {
if len(membersToAdd) > 0 && len(membersToAdd) > len(alreadyMembers.Members) {
if err := api.Organization.AddMembers(organizationID, membersToAdd); err != nil {
return diag.FromErr(err)
}
Expand Down
3 changes: 3 additions & 0 deletions internal/auth0/organization/resource_members_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,9 @@ func TestAccOrganizationMembers(t *testing.T) {
Config: acctest.ParseTestName(testAccOrganizationMembersPreventErasingMembersOnCreate, testName),
ExpectError: regexp.MustCompile("Organization with non empty members"),
},
{
Config: acctest.ParseTestName(testAccOrganizationMembersRemoveAllMembers, testName),
},
{
Config: acctest.ParseTestName(testAccOrganizationMembersWithOneMember, testName),
Check: resource.ComposeTestCheckFunc(
Expand Down
Loading

0 comments on commit e8bf000

Please sign in to comment.