Skip to content

Commit

Permalink
Update project shared_with_groups: improve acceptance tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Jordan Caussat committed Feb 8, 2019
1 parent 0a261de commit 1a159c2
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions gitlab/resource_gitlab_project_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func TestAccGitlabProject_basic(t *testing.T) {
GroupID int
GroupName string
GroupAccessLevel int
}{{0, "", 30}},
}{{0, fmt.Sprintf("foo-name-%d", rInt), 30}},
}),
),
},
Expand All @@ -106,7 +106,7 @@ func TestAccGitlabProject_basic(t *testing.T) {
GroupID int
GroupName string
GroupAccessLevel int
}{{0, "", 30}, {0, "", 10}},
}{{0, fmt.Sprintf("foo-name-%d", rInt), 10}, {0, fmt.Sprintf("foo2-name-%d", rInt), 30}},
}),
),
},
Expand Down Expand Up @@ -251,11 +251,18 @@ func testAccCheckGitlabProjectAttributes(project *gitlab.Project, want *testAccG
return fmt.Errorf("got visibility %q; want %q", project.Visibility, want.Visibility)
}

for i, group := range project.SharedWithGroups {
if group.GroupAccessLevel != want.SharedWithGroups[i].GroupAccessLevel {
return fmt.Errorf("got shared with groups access: %d; want %d", group.GroupAccessLevel, want.SharedWithGroups[i].GroupAccessLevel)
groupsToCheck := want.SharedWithGroups
for _, group := range project.SharedWithGroups {
for i, groupToCheck := range groupsToCheck {
if group.GroupName == groupToCheck.GroupName && group.GroupAccessLevel == groupToCheck.GroupAccessLevel {
groupsToCheck = append(groupsToCheck[:i], groupsToCheck[i+1:]...)
break
}
}
}
if len(groupsToCheck) != 0 {
return fmt.Errorf("got shared with groups: %v; want %v", project.SharedWithGroups, want.SharedWithGroups)
}

return nil
}
Expand Down

0 comments on commit 1a159c2

Please sign in to comment.