From 07a53abbf98232aaca81c3cf1c19b2baaf93599b Mon Sep 17 00:00:00 2001 From: Kevin Zhao Date: Thu, 4 Feb 2021 15:24:27 -0800 Subject: [PATCH 1/7] First attempt --- github/resource_github_team_repository.go | 29 +++++++++++---------- github/util.go | 31 +++++++++++++++++++++++ 2 files changed, 46 insertions(+), 14 deletions(-) diff --git a/github/resource_github_team_repository.go b/github/resource_github_team_repository.go index d59535ea5a..2e8b0ca8b4 100644 --- a/github/resource_github_team_repository.go +++ b/github/resource_github_team_repository.go @@ -25,7 +25,7 @@ func resourceGithubTeamRepository() *schema.Resource { Type: schema.TypeString, Required: true, ForceNew: true, - ValidateFunc: validateTeamIDFunc, + Description: "ID or slug of team", }, "repository": { Type: schema.TypeString, @@ -55,18 +55,17 @@ func resourceGithubTeamRepositoryCreate(d *schema.ResourceData, meta interface{} client := meta.(*Owner).v3client orgId := meta.(*Owner).id - teamIdString := d.Get("team_id").(string) - teamId, err := strconv.ParseInt(teamIdString, 10, 64) - if err != nil { - return unconvertibleIdErr(teamIdString, err) - } + // The given team id could be an id or a slug + givenTeamId := d.Get("team_id").(string) + teamId, err := getTeamID(givenTeamId, meta) + orgName := meta.(*Owner).name repoName := d.Get("repository").(string) permission := d.Get("permission").(string) ctx := context.Background() log.Printf("[DEBUG] Creating team repository association: %s:%s (%s/%s)", - teamIdString, permission, orgName, repoName) + givenTeamId, permission, orgName, repoName) _, err = client.Teams.AddTeamRepoByID(ctx, orgId, teamId, @@ -81,7 +80,7 @@ func resourceGithubTeamRepositoryCreate(d *schema.ResourceData, meta interface{} return err } - d.SetId(buildTwoPartID(teamIdString, repoName)) + d.SetId(buildTwoPartID(strconv.FormatInt(teamId, 10), repoName)) return resourceGithubTeamRepositoryRead(d, meta) } @@ -99,7 +98,6 @@ func resourceGithubTeamRepositoryRead(d *schema.ResourceData, meta interface{}) if err != nil { return err } - teamId, err := strconv.ParseInt(teamIdString, 10, 64) if err != nil { return unconvertibleIdErr(teamIdString, err) @@ -150,13 +148,15 @@ func resourceGithubTeamRepositoryUpdate(d *schema.ResourceData, meta interface{} client := meta.(*Owner).v3client orgId := meta.(*Owner).id - teamIdString := d.Get("team_id").(string) + teamIdString, repoName, err := parseTwoPartID(d.Id(), "team_id", "repository") + if err != nil { + return err + } teamId, err := strconv.ParseInt(teamIdString, 10, 64) if err != nil { return unconvertibleIdErr(teamIdString, err) } orgName := meta.(*Owner).name - repoName := d.Get("repository").(string) permission := d.Get("permission").(string) ctx := context.WithValue(context.Background(), ctxId, d.Id()) @@ -190,14 +190,15 @@ func resourceGithubTeamRepositoryDelete(d *schema.ResourceData, meta interface{} client := meta.(*Owner).v3client orgId := meta.(*Owner).id - teamIdString := d.Get("team_id").(string) - + teamIdString, repoName, err := parseTwoPartID(d.Id(), "team_id", "repository") + if err != nil { + return err + } teamId, err := strconv.ParseInt(teamIdString, 10, 64) if err != nil { return unconvertibleIdErr(teamIdString, err) } orgName := meta.(*Owner).name - repoName := d.Get("repository").(string) ctx := context.WithValue(context.Background(), ctxId, d.Id()) log.Printf("[DEBUG] Deleting team repository association: %s (%s/%s)", diff --git a/github/util.go b/github/util.go index 3b82a0cf45..17cb9e92ea 100644 --- a/github/util.go +++ b/github/util.go @@ -1,6 +1,8 @@ package github import ( + "context" + "errors" "fmt" "strconv" "strings" @@ -110,3 +112,32 @@ func splitRepoFilePath(path string) (string, string) { parts := strings.Split(path, "/") return parts[0], strings.Join(parts[1:], "/") } + +func getTeamID(teamIDString string, meta interface{}) (int64, error) { + ctx := context.Background() + client := meta.(*Owner).v3client + orgName := meta.(*Owner).name + orgId := meta.(*Owner).id + + teamId, parseIntErr := strconv.ParseInt(teamIDString, 10, 64) + if parseIntErr != nil { + // The given id not an integer, assume it is a team slug + team, _, slugErr := client.Teams.GetTeamBySlug(ctx, orgName, teamIDString) + if slugErr != nil { + return -1, errors.New(parseIntErr.Error() + slugErr.Error()) + } + return team.GetID(), nil + } else { + // The given id is an integer, assume it is a team id + team, _, teamIdErr := client.Teams.GetTeamByID(ctx, orgId, teamId) + if teamIdErr != nil { + // There isn't a team with the given ID, assume it is a teamslug + team, _, slugErr := client.Teams.GetTeamBySlug(ctx, orgName, teamIDString) + if slugErr != nil { + return -1, errors.New(teamIdErr.Error() + slugErr.Error()) + } + return team.GetID(), nil + } + return team.GetID(), nil + } +} From 4110c4732add821e9cd4ac1d9b7d63520ec4182b Mon Sep 17 00:00:00 2001 From: Kevin Zhao Date: Thu, 4 Feb 2021 16:09:03 -0800 Subject: [PATCH 2/7] Add comment --- github/util.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/github/util.go b/github/util.go index 17cb9e92ea..3c7f147dcc 100644 --- a/github/util.go +++ b/github/util.go @@ -114,6 +114,8 @@ func splitRepoFilePath(path string) (string, string) { } func getTeamID(teamIDString string, meta interface{}) (int64, error) { + // Given a string that is either a team id or team slug, return the + // id of the team it is referring to. ctx := context.Background() client := meta.(*Owner).v3client orgName := meta.(*Owner).name From bcafe1d422802fbd5dee79285497cae7c12d9e5c Mon Sep 17 00:00:00 2001 From: Kevin Zhao Date: Thu, 4 Feb 2021 16:39:16 -0800 Subject: [PATCH 3/7] Attempt to modify unit tests --- .../resource_github_team_repository_test.go | 70 +++++++++++-------- 1 file changed, 40 insertions(+), 30 deletions(-) diff --git a/github/resource_github_team_repository_test.go b/github/resource_github_team_repository_test.go index 9d546b2946..ab2d6146ea 100644 --- a/github/resource_github_team_repository_test.go +++ b/github/resource_github_team_repository_test.go @@ -23,31 +23,41 @@ func TestAccGithubTeamRepository_basic(t *testing.T) { randString := acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum) repoName := fmt.Sprintf("tf-acc-test-team-%s", acctest.RandString(5)) - resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckGithubTeamRepositoryDestroy, - Steps: []resource.TestStep{ - { - Config: testAccGithubTeamRepositoryConfig(randString, repoName), - Check: resource.ComposeTestCheckFunc( - testAccCheckGithubTeamRepositoryExists(rn, &repository), - testAccCheckGithubTeamRepositoryRoleState("pull", &repository), - ), + testCase := func(t *testing.T, teamIdentifier string) { + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckGithubTeamRepositoryDestroy, + Steps: []resource.TestStep{ + { + Config: testAccGithubTeamRepositoryConfig(randString, repoName, teamIdentifier), + Check: resource.ComposeTestCheckFunc( + testAccCheckGithubTeamRepositoryExists(rn, &repository), + testAccCheckGithubTeamRepositoryRoleState("pull", &repository), + ), + }, + { + Config: testAccGithubTeamRepositoryUpdateConfig(randString, repoName, teamIdentifier), + Check: resource.ComposeTestCheckFunc( + testAccCheckGithubTeamRepositoryExists(rn, &repository), + testAccCheckGithubTeamRepositoryRoleState("push", &repository), + ), + }, + { + ResourceName: rn, + ImportState: true, + ImportStateVerify: true, + }, }, - { - Config: testAccGithubTeamRepositoryUpdateConfig(randString, repoName), - Check: resource.ComposeTestCheckFunc( - testAccCheckGithubTeamRepositoryExists(rn, &repository), - testAccCheckGithubTeamRepositoryRoleState("push", &repository), - ), - }, - { - ResourceName: rn, - ImportState: true, - ImportStateVerify: true, - }, - }, + }) + } + + t.Run("with a team id identifier", func(t *testing.T) { + testCase(t, "id") + }) + + t.Run("with a team slug identifier", func(t *testing.T) { + testCase(t, "slug") }) } @@ -178,7 +188,7 @@ func testAccCheckGithubTeamRepositoryDestroy(s *terraform.State) error { return nil } -func testAccGithubTeamRepositoryConfig(randString, repoName string) string { +func testAccGithubTeamRepositoryConfig(randString, repoName string, teamIdentifier string) string { return fmt.Sprintf(` resource "github_team" "test_team" { name = "tf-acc-test-team-repo-%s" @@ -190,14 +200,14 @@ resource "github_repository" "test" { } resource "github_team_repository" "test_team_test_repo" { - team_id = "${github_team.test_team.id}" + team_id = "${github_team.test_team.%s}" repository = "${github_repository.test.name}" permission = "pull" } -`, randString, repoName) +`, randString, repoName, teamIdentifier) } -func testAccGithubTeamRepositoryUpdateConfig(randString, repoName string) string { +func testAccGithubTeamRepositoryUpdateConfig(randString, repoName string, teamIdentifier string) string { return fmt.Sprintf(` resource "github_team" "test_team" { name = "tf-acc-test-team-repo-%s" @@ -209,9 +219,9 @@ resource "github_repository" "test" { } resource "github_team_repository" "test_team_test_repo" { - team_id = "${github_team.test_team.id}" + team_id = "${github_team.test_team.%s}" repository = "${github_repository.test.name}" permission = "push" } -`, randString, repoName) +`, randString, repoName, teamIdentifier) } From 3c21151a38554d090da795046724b61c850792e5 Mon Sep 17 00:00:00 2001 From: Kevin Zhao Date: Thu, 4 Feb 2021 16:40:13 -0800 Subject: [PATCH 4/7] Edit docs to reflect change --- website/docs/r/team_repository.html.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs/r/team_repository.html.markdown b/website/docs/r/team_repository.html.markdown index de2c91cb8a..9d8cb84ccf 100644 --- a/website/docs/r/team_repository.html.markdown +++ b/website/docs/r/team_repository.html.markdown @@ -41,7 +41,7 @@ resource "github_team_repository" "some_team_repo" { The following arguments are supported: -* `team_id` - (Required) The GitHub team id +* `team_id` - (Required) The GitHub team id or the GitHub team slug * `repository` - (Required) The repository to add to the team. * `permission` - (Optional) The permissions of team members regarding the repository. Must be one of `pull`, `triage`, `push`, `maintain`, or `admin`. Defaults to `pull`. From 37e313bb9333edb5adcc97dadc689031a6b213a4 Mon Sep 17 00:00:00 2001 From: Kevin Zhao Date: Thu, 4 Feb 2021 16:56:16 -0800 Subject: [PATCH 5/7] Make sure team_id is set appropriately --- github/resource_github_team_repository.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/github/resource_github_team_repository.go b/github/resource_github_team_repository.go index 2e8b0ca8b4..2c0cb6eb58 100644 --- a/github/resource_github_team_repository.go +++ b/github/resource_github_team_repository.go @@ -126,7 +126,11 @@ func resourceGithubTeamRepositoryRead(d *schema.ResourceData, meta interface{}) } d.Set("etag", resp.Header.Get("ETag")) - d.Set("team_id", teamIdString) + if d.Get("team_id") == "" { + // If team_id is empty, that means we are importing the resource. + // Set the team_id to be the id of the team. + d.Set("team_id", teamIdString) + } d.Set("repository", repo.GetName()) permName, permErr := getRepoPermission(repo.GetPermissions()) From 265d62dae428792acb33e958e7c8b9391270cbb7 Mon Sep 17 00:00:00 2001 From: Kevin Zhao Date: Thu, 4 Feb 2021 18:05:57 -0800 Subject: [PATCH 6/7] fixing lint --- github/resource_github_team_repository.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/github/resource_github_team_repository.go b/github/resource_github_team_repository.go index 2c0cb6eb58..0091b0f786 100644 --- a/github/resource_github_team_repository.go +++ b/github/resource_github_team_repository.go @@ -22,10 +22,10 @@ func resourceGithubTeamRepository() *schema.Resource { Schema: map[string]*schema.Schema{ "team_id": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - Description: "ID or slug of team", + Type: schema.TypeString, + Required: true, + ForceNew: true, + Description: "ID or slug of team", }, "repository": { Type: schema.TypeString, @@ -58,6 +58,9 @@ func resourceGithubTeamRepositoryCreate(d *schema.ResourceData, meta interface{} // The given team id could be an id or a slug givenTeamId := d.Get("team_id").(string) teamId, err := getTeamID(givenTeamId, meta) + if err != nil { + return err + } orgName := meta.(*Owner).name repoName := d.Get("repository").(string) From 62e5fc1124097fb6b8c5ba2293b4086a65ca9e56 Mon Sep 17 00:00:00 2001 From: Jeremy Udit Date: Wed, 10 Feb 2021 19:20:27 -0500 Subject: [PATCH 7/7] add passing tests for `github_team_repository` --- .../resource_github_team_repository_test.go | 336 ++++++++---------- 1 file changed, 141 insertions(+), 195 deletions(-) diff --git a/github/resource_github_team_repository_test.go b/github/resource_github_team_repository_test.go index ab2d6146ea..1df45f6de4 100644 --- a/github/resource_github_team_repository_test.go +++ b/github/resource_github_team_repository_test.go @@ -1,227 +1,173 @@ package github import ( - "context" "fmt" - "strconv" + "strings" "testing" - "github.com/google/go-github/v32/github" "github.com/hashicorp/terraform-plugin-sdk/helper/acctest" "github.com/hashicorp/terraform-plugin-sdk/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/terraform" ) -func TestAccGithubTeamRepository_basic(t *testing.T) { - if err := testAccCheckOrganization(); err != nil { - t.Skipf("Skipping because %s.", err.Error()) - } - - var repository github.Repository - - rn := "github_team_repository.test_team_test_repo" - randString := acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum) - repoName := fmt.Sprintf("tf-acc-test-team-%s", acctest.RandString(5)) - - testCase := func(t *testing.T, teamIdentifier string) { - resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckGithubTeamRepositoryDestroy, - Steps: []resource.TestStep{ - { - Config: testAccGithubTeamRepositoryConfig(randString, repoName, teamIdentifier), - Check: resource.ComposeTestCheckFunc( - testAccCheckGithubTeamRepositoryExists(rn, &repository), - testAccCheckGithubTeamRepositoryRoleState("pull", &repository), - ), - }, - { - Config: testAccGithubTeamRepositoryUpdateConfig(randString, repoName, teamIdentifier), - Check: resource.ComposeTestCheckFunc( - testAccCheckGithubTeamRepositoryExists(rn, &repository), - testAccCheckGithubTeamRepositoryRoleState("push", &repository), - ), - }, - { - ResourceName: rn, - ImportState: true, - ImportStateVerify: true, - }, - }, - }) - } - - t.Run("with a team id identifier", func(t *testing.T) { - testCase(t, "id") - }) +func TestAccGithubTeamRepository(t *testing.T) { - t.Run("with a team slug identifier", func(t *testing.T) { - testCase(t, "slug") - }) -} + randomID := acctest.RandStringFromCharSet(5, acctest.CharSetAlphaNum) -func TestAccCheckGetPermissions(t *testing.T) { - pullMap := map[string]bool{"pull": true, "triage": false, "push": false, "maintain": false, "admin": false} - triageMap := map[string]bool{"pull": false, "triage": true, "push": false, "maintain": false, "admin": false} - pushMap := map[string]bool{"pull": true, "triage": false, "push": true, "maintain": false, "admin": false} - maintainMap := map[string]bool{"pull": false, "triage": false, "push": false, "maintain": true, "admin": false} - adminMap := map[string]bool{"pull": true, "triage": false, "push": true, "maintain": false, "admin": true} - errorMap := map[string]bool{"pull": false, "triage": false, "push": false, "maintain": false, "admin": false} - - pull, _ := getRepoPermission(pullMap) - if pull != "pull" { - t.Fatalf("Expected pull permission, actual: %s", pull) - } - - triage, _ := getRepoPermission(triageMap) - if triage != "triage" { - t.Fatalf("Expected triage permission, actual: %s", triage) - } - - push, _ := getRepoPermission(pushMap) - if push != "push" { - t.Fatalf("Expected push permission, actual: %s", push) - } - - maintain, _ := getRepoPermission(maintainMap) - if maintain != "maintain" { - t.Fatalf("Expected maintain permission, actual: %s", maintain) - } - - admin, _ := getRepoPermission(adminMap) - if admin != "admin" { - t.Fatalf("Expected admin permission, actual: %s", admin) - } - - errPerm, err := getRepoPermission(errorMap) - if err == nil { - t.Fatalf("Expected an error getting permissions, actual: %v", errPerm) - } -} + t.Run("manages team permissions to a repository", func(t *testing.T) { -func testAccCheckGithubTeamRepositoryRoleState(role string, repository *github.Repository) resource.TestCheckFunc { - return func(s *terraform.State) error { - resourceRole, err := getRepoPermission(repository.GetPermissions()) - if err != nil { - return err - } + config := fmt.Sprintf(` + resource "github_team" "test" { + name = "tf-acc-test-team-repo-%s" + description = "test" + } - if resourceRole != role { - return fmt.Errorf("Team repository role %v in resource does match expected state of %v", resourceRole, role) - } - return nil - } -} + resource "github_repository" "test" { + name = "tf-acc-test-%[1]s" + } -func testAccCheckGithubTeamRepositoryExists(n string, repository *github.Repository) resource.TestCheckFunc { - return func(s *terraform.State) error { - rs, ok := s.RootModule().Resources[n] - if !ok { - return fmt.Errorf("Not Found: %s", n) + resource "github_team_repository" "test" { + team_id = "${github_team.test.id}" + repository = "${github_repository.test.name}" + permission = "pull" + } + `, randomID) + + checks := map[string]resource.TestCheckFunc{ + "pull": resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr( + "github_team_repository.test", "permission", + "pull", + ), + ), + "triage": resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr( + "github_team_repository.test", "permission", + "triage", + ), + ), + "push": resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr( + "github_team_repository.test", "permission", + "push", + ), + ), + "maintain": resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr( + "github_team_repository.test", "permission", + "maintain", + ), + ), + "admin": resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr( + "github_team_repository.test", "permission", + "admin", + ), + ), } - if rs.Primary.ID == "" { - return fmt.Errorf("No team repository ID is set") + testCase := func(t *testing.T, mode string) { + resource.Test(t, resource.TestCase{ + PreCheck: func() { skipUnlessMode(t, mode) }, + Providers: testAccProviders, + Steps: []resource.TestStep{ + { + Config: config, + Check: checks["pull"], + }, + { + Config: strings.Replace(config, + `permission = "pull"`, + `permission = "triage"`, 1), + Check: checks["triage"], + }, + { + Config: strings.Replace(config, + `permission = "pull"`, + `permission = "push"`, 1), + Check: checks["push"], + }, + { + Config: strings.Replace(config, + `permission = "pull"`, + `permission = "maintain"`, 1), + Check: checks["maintain"], + }, + { + Config: strings.Replace(config, + `permission = "pull"`, + `permission = "admin"`, 1), + Check: checks["admin"], + }, + }, + }) } - conn := testAccProvider.Meta().(*Owner).v3client - - teamIdString, repoName, err := parseTwoPartID(rs.Primary.ID, "team_id", "repository") - if err != nil { - return err - } - teamId, err := strconv.ParseInt(teamIdString, 10, 64) - if err != nil { - return unconvertibleIdErr(teamIdString, err) - } + t.Run("with an anonymous account", func(t *testing.T) { + t.Skip("anonymous account not supported for this operation") + }) - repo, _, err := conn.Teams.IsTeamRepoByID(context.TODO(), - testAccProvider.Meta().(*Owner).id, - teamId, - testAccProvider.Meta().(*Owner).name, - repoName) + t.Run("with an individual account", func(t *testing.T) { + t.Skip("individual account not supported for this operation") + }) - if err != nil { - return err - } - *repository = *repo - return nil - } -} + t.Run("with an organization account", func(t *testing.T) { + testCase(t, organization) + }) -func testAccCheckGithubTeamRepositoryDestroy(s *terraform.State) error { - conn := testAccProvider.Meta().(*Owner).v3client - orgId := testAccProvider.Meta().(*Owner).id + }) - for _, rs := range s.RootModule().Resources { - if rs.Type != "github_team_repository" { - continue - } + t.Run("accepts both team slug and team ID for `team_id`", func(t *testing.T) { - teamIdString, repoName, err := parseTwoPartID(rs.Primary.ID, "team_id", "repository") - if err != nil { - return err - } - teamId, err := strconv.ParseInt(teamIdString, 10, 64) - if err != nil { - return unconvertibleIdErr(teamIdString, err) - } + config := fmt.Sprintf(` + resource "github_team" "test" { + name = "tf-acc-test-team-repo-%s" + description = "test" + } - repo, resp, err := conn.Teams.IsTeamRepoByID(context.TODO(), - orgId, - teamId, - testAccProvider.Meta().(*Owner).name, - repoName) + resource "github_repository" "test" { + name = "tf-acc-test-%[1]s" + } - if err == nil { - if repo != nil && - buildTwoPartID(teamIdString, repo.GetName()) == rs.Primary.ID { - return fmt.Errorf("Team repository still exists") + resource "github_team_repository" "test" { + team_id = "${github_team.test.slug}" + repository = "${github_repository.test.name}" + permission = "pull" } + `, randomID) + + check := resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttrSet("github_team_repository.test", "team_id"), + ) + + testCase := func(t *testing.T, mode string) { + resource.Test(t, resource.TestCase{ + PreCheck: func() { skipUnlessMode(t, mode) }, + Providers: testAccProviders, + Steps: []resource.TestStep{ + { + Config: config, + Check: check, + }, + { + Config: strings.Replace(config, + `github_team.test.id`, + `github_team.test.slug`, 1), + Check: check, + }, + }, + }) } - if resp.StatusCode != 404 { - return err - } - return nil - } - return nil -} -func testAccGithubTeamRepositoryConfig(randString, repoName string, teamIdentifier string) string { - return fmt.Sprintf(` -resource "github_team" "test_team" { - name = "tf-acc-test-team-repo-%s" - description = "Terraform acc test group" -} - -resource "github_repository" "test" { - name = "%s" -} - -resource "github_team_repository" "test_team_test_repo" { - team_id = "${github_team.test_team.%s}" - repository = "${github_repository.test.name}" - permission = "pull" -} -`, randString, repoName, teamIdentifier) -} - -func testAccGithubTeamRepositoryUpdateConfig(randString, repoName string, teamIdentifier string) string { - return fmt.Sprintf(` -resource "github_team" "test_team" { - name = "tf-acc-test-team-repo-%s" - description = "Terraform acc test group" -} + t.Run("with an anonymous account", func(t *testing.T) { + t.Skip("anonymous account not supported for this operation") + }) -resource "github_repository" "test" { - name = "%s" -} + t.Run("with an individual account", func(t *testing.T) { + t.Skip("individual account not supported for this operation") + }) -resource "github_team_repository" "test_team_test_repo" { - team_id = "${github_team.test_team.%s}" - repository = "${github_repository.test.name}" - permission = "push" -} -`, randString, repoName, teamIdentifier) + t.Run("with an organization account", func(t *testing.T) { + testCase(t, organization) + }) + }) }