Skip to content

Commit

Permalink
Improbe Test: depends_on
Browse files Browse the repository at this point in the history
  • Loading branch information
jbenaventem authored Jun 2, 2021
1 parent b43ee38 commit 775ac55
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 27 deletions.
48 changes: 21 additions & 27 deletions github/data_source_github_team_repository_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -53,8 +46,9 @@ func TestAccGithubTeamRepositorty(t *testing.T) {
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: config,
Check: check,
Config: config,
Check: check,
ExpectNonEmptyPlan: true,
},
},
})
Expand Down
2 changes: 2 additions & 0 deletions website/docs/d/team.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 775ac55

Please sign in to comment.