Skip to content

Commit ea0ef30

Browse files
committed
Fix TestAccGithubRepositoryCollaborators to not use external user
Signed-off-by: Timo Sand <[email protected]>
1 parent b617b4e commit ea0ef30

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

github/resource_github_repository_collaborators_test.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ func TestAccGithubRepositoryCollaborators(t *testing.T) {
9696
randomID := acctest.RandStringFromCharSet(5, acctest.CharSetAlphaNum)
9797
repoName := fmt.Sprintf("%srepo-collabs-%s", testResourcePrefix, randomID)
9898
teamName := fmt.Sprintf("%steam-collabs-%s", testResourcePrefix, randomID)
99+
collaboratorUser := testAccConf.testOrgUser
99100

100101
config := fmt.Sprintf(`
101102
resource "github_repository" "test" {
@@ -121,7 +122,7 @@ func TestAccGithubRepositoryCollaborators(t *testing.T) {
121122
permission = "pull"
122123
}
123124
}
124-
`, repoName, teamName, testAccConf.testExternalUser)
125+
`, repoName, teamName, collaboratorUser)
125126

126127
resource.Test(t, resource.TestCase{
127128
PreCheck: func() { skipUnlessHasOrgs(t) },
@@ -140,8 +141,8 @@ func TestAccGithubRepositoryCollaborators(t *testing.T) {
140141
teamAttrs := state.RootModule().Resources["github_team.test"].Primary.Attributes
141142
collaborators := state.RootModule().Resources["github_repository_collaborators.test_repo_collaborators"].Primary
142143
for name, val := range collaborators.Attributes {
143-
if strings.HasPrefix(name, "user.") && strings.HasSuffix(name, ".username") && val != testAccConf.testExternalUser {
144-
return fmt.Errorf("expected user.*.username to be set to %s, was %s", testAccConf.testExternalUser, val)
144+
if strings.HasPrefix(name, "user.") && strings.HasSuffix(name, ".username") && val != collaboratorUser {
145+
return fmt.Errorf("expected user.*.username to be set to %s, was %s", collaboratorUser, val)
145146
}
146147
if strings.HasPrefix(name, "user.") && strings.HasSuffix(name, ".permission") && val != "admin" {
147148
return fmt.Errorf("expected user.*.permission to be set to admin, was %s", val)
@@ -158,11 +159,11 @@ func TestAccGithubRepositoryCollaborators(t *testing.T) {
158159
return err
159160
}
160161
if len(users) != 1 {
161-
return fmt.Errorf("expected %s to be a collaborator for repo %s/%s", testAccConf.testExternalUser, owner, repoName)
162+
return fmt.Errorf("expected 1 collaborator (%s) for repo %s/%s , found %d", collaboratorUser, owner, repoName, len(users))
162163
}
163164
perm := getPermission(users[0].GetRoleName())
164165
if perm != "admin" {
165-
return fmt.Errorf("expected %s to have admin perms for repo %s/%s, found %s", testAccConf.testExternalUser, owner, repoName, perm)
166+
return fmt.Errorf("expected %s to have admin perms for repo %s/%s, found %s", collaboratorUser, owner, repoName, perm)
166167
}
167168
teams, _, err := conn.Repositories.ListTeams(ctx, owner, repoName, nil)
168169
if err != nil {

0 commit comments

Comments
 (0)