From 775ac55a79e35fcb0dd36a8292795ce5a65e57e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Benavente?= Date: Wed, 2 Jun 2021 15:57:36 +0000 Subject: [PATCH] Improbe Test: depends_on --- ...data_source_github_team_repository_test.go | 48 ++++++++----------- website/docs/d/team.html.markdown | 2 + 2 files changed, 23 insertions(+), 27 deletions(-) diff --git a/github/data_source_github_team_repository_test.go b/github/data_source_github_team_repository_test.go index 68e31b9607..e0a47ac950 100644 --- a/github/data_source_github_team_repository_test.go +++ b/github/data_source_github_team_repository_test.go @@ -8,43 +8,36 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/helper/resource" ) -func TestAccGithubTeamRepositorty(t *testing.T) { +func TestAccGithubTeamRepositories(t *testing.T) { randomID := acctest.RandStringFromCharSet(5, acctest.CharSetAlphaNum) t.Run("Get Repositories By Teams", func(t *testing.T) { config := fmt.Sprintf(` - resource "github_repository" "repo-test" { - name = "tf-acc-repo-%s" - auto_init = true - - } - - resource "github_team" "team-test" { - name = "tf-acc-test-team01" - } - - resource "github_team_repository" "team-repo-test" { - repository = "${github_repository.repo-test.id}" - team_id = "${github_team.team-test.id}" - } - data "github_team" "example" { - slug = "team-test-01" - } + resource "github_repository" "test" { + name = "tf-acc-test-%s" + auto_init = true + } - output "team_repository_name" { - value = data.github_team.example.repositories.0 - } + resource "github_team" "test" { + name = "tf-acc-test-%[1]s" + } - output "team_repository_numbers" { - value = data.github_team.example.repositories.# - } + resource "github_team_repository" "test" { + team_id = "${github_team.test.id}" + repository = "${github_repository.test.name}" + } + + data "github_team" "example" { + depends_on = ["github_repository.test", "github_team.test", "github_team_repository.test"] + slug = github_team.test.slug + } `, randomID) check := resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttrSet("data.github_team.example", "name"), + resource.TestCheckResourceAttr("data.github_team.example", "repositories.#", "1"), ) testCase := func(t *testing.T, mode string) { @@ -53,8 +46,9 @@ func TestAccGithubTeamRepositorty(t *testing.T) { Providers: testAccProviders, Steps: []resource.TestStep{ { - Config: config, - Check: check, + Config: config, + Check: check, + ExpectNonEmptyPlan: true, }, }, }) diff --git a/website/docs/d/team.html.markdown b/website/docs/d/team.html.markdown index bfe2d1b1ff..a5f348de2c 100644 --- a/website/docs/d/team.html.markdown +++ b/website/docs/d/team.html.markdown @@ -30,3 +30,5 @@ data "github_team" "example" { * `privacy` - the team's privacy type. * `permission` - the team's permission level. * `members` - List of team members + * `repositories` - List of team repositories +