Skip to content

Commit

Permalink
fix: support team slug in github_team_membership (#1751)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kristián Leško authored Jun 26, 2023
1 parent 8c7b824 commit b831318
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
9 changes: 4 additions & 5 deletions github/resource_github_team_membership.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,10 @@ func resourceGithubTeamMembership() *schema.Resource {

Schema: map[string]*schema.Schema{
"team_id": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
Description: "The GitHub team id or the GitHub team slug.",
ValidateFunc: validateTeamIDFunc,
Type: schema.TypeString,
Required: true,
ForceNew: true,
Description: "The GitHub team id or the GitHub team slug.",
},
"username": {
Type: schema.TypeString,
Expand Down
23 changes: 22 additions & 1 deletion github/resource_github_team_membership_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ func TestAccGithubTeamMembership_basic(t *testing.T) {
var membership github.Membership

rn := "github_team_membership.test_team_membership"
rns := "github_team_membership.test_team_membership_slug"
randString := acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)

resource.ParallelTest(t, resource.TestCase{
Expand All @@ -36,20 +37,29 @@ func TestAccGithubTeamMembership_basic(t *testing.T) {
Check: resource.ComposeTestCheckFunc(
testAccCheckGithubTeamMembershipExists(rn, &membership),
testAccCheckGithubTeamMembershipRoleState(rn, "member", &membership),
testAccCheckGithubTeamMembershipExists(rns, &membership),
testAccCheckGithubTeamMembershipRoleState(rns, "member", &membership),
),
},
{
Config: testAccGithubTeamMembershipConfig(randString, testCollaborator, "maintainer"),
Check: resource.ComposeTestCheckFunc(
testAccCheckGithubTeamMembershipExists(rn, &membership),
testAccCheckGithubTeamMembershipRoleState(rn, "maintainer", &membership),
testAccCheckGithubTeamMembershipExists(rns, &membership),
testAccCheckGithubTeamMembershipRoleState(rns, "maintainer", &membership),
),
},
{
ResourceName: rn,
ImportState: true,
ImportStateVerify: true,
},
{
ResourceName: rns,
ImportState: true,
ImportStateVerify: true,
},
},
})
}
Expand Down Expand Up @@ -222,12 +232,23 @@ resource "github_team" "test_team" {
description = "Terraform acc test group"
}
resource "github_team" "test_team_slug" {
name = "tf-acc-test-team-membership-%s-slug"
description = "Terraform acc test group"
}
resource "github_team_membership" "test_team_membership" {
team_id = "${github_team.test_team.id}"
username = "%s"
role = "%s"
}
`, username, randString, username, role)
resource "github_team_membership" "test_team_membership_slug" {
team_id = "${github_team.test_team_slug.slug}"
username = "%s"
role = "%s"
}
`, username, randString, randString, username, role, username, role)
}

func testAccGithubTeamMembershipTheSame(orig, other *github.Membership) resource.TestCheckFunc {
Expand Down

0 comments on commit b831318

Please sign in to comment.