Merge pull request #14460 from hashicorp/b-github-test-repo
provider/github: Randomize acceptance tests
This commit is contained in:
commit
65af35fb25
|
@ -8,8 +8,6 @@ import (
|
||||||
"github.com/hashicorp/terraform/terraform"
|
"github.com/hashicorp/terraform/terraform"
|
||||||
)
|
)
|
||||||
|
|
||||||
const testRepo string = "test-repo"
|
|
||||||
|
|
||||||
var testUser string = os.Getenv("GITHUB_TEST_USER")
|
var testUser string = os.Getenv("GITHUB_TEST_USER")
|
||||||
var testCollaborator string = os.Getenv("GITHUB_TEST_COLLABORATOR")
|
var testCollaborator string = os.Getenv("GITHUB_TEST_COLLABORATOR")
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/google/go-github/github"
|
"github.com/google/go-github/github"
|
||||||
|
"github.com/hashicorp/terraform/helper/acctest"
|
||||||
"github.com/hashicorp/terraform/helper/resource"
|
"github.com/hashicorp/terraform/helper/resource"
|
||||||
"github.com/hashicorp/terraform/terraform"
|
"github.com/hashicorp/terraform/terraform"
|
||||||
)
|
)
|
||||||
|
@ -14,18 +15,21 @@ import (
|
||||||
func TestAccGithubBranchProtection_basic(t *testing.T) {
|
func TestAccGithubBranchProtection_basic(t *testing.T) {
|
||||||
var protection github.Protection
|
var protection github.Protection
|
||||||
|
|
||||||
|
rString := acctest.RandString(5)
|
||||||
|
repoName := fmt.Sprintf("tf-acc-test-branch-prot-%s", rString)
|
||||||
|
|
||||||
resource.Test(t, resource.TestCase{
|
resource.Test(t, resource.TestCase{
|
||||||
PreCheck: func() { testAccPreCheck(t) },
|
PreCheck: func() { testAccPreCheck(t) },
|
||||||
Providers: testAccProviders,
|
Providers: testAccProviders,
|
||||||
CheckDestroy: testAccGithubBranchProtectionDestroy,
|
CheckDestroy: testAccGithubBranchProtectionDestroy,
|
||||||
Steps: []resource.TestStep{
|
Steps: []resource.TestStep{
|
||||||
{
|
{
|
||||||
Config: testAccGithubBranchProtectionConfig,
|
Config: testAccGithubBranchProtectionConfig(repoName),
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccCheckGithubProtectedBranchExists("github_branch_protection.master", &protection),
|
testAccCheckGithubProtectedBranchExists("github_branch_protection.master", repoName+":master", &protection),
|
||||||
testAccCheckGithubBranchProtectionRequiredStatusChecks(&protection, true, true, []string{"github/foo"}),
|
testAccCheckGithubBranchProtectionRequiredStatusChecks(&protection, true, true, []string{"github/foo"}),
|
||||||
testAccCheckGithubBranchProtectionRestrictions(&protection, []string{testUser}, []string{}),
|
testAccCheckGithubBranchProtectionRestrictions(&protection, []string{testUser}, []string{}),
|
||||||
resource.TestCheckResourceAttr("github_branch_protection.master", "repository", testRepo),
|
resource.TestCheckResourceAttr("github_branch_protection.master", "repository", repoName),
|
||||||
resource.TestCheckResourceAttr("github_branch_protection.master", "branch", "master"),
|
resource.TestCheckResourceAttr("github_branch_protection.master", "branch", "master"),
|
||||||
resource.TestCheckResourceAttr("github_branch_protection.master", "required_status_checks.0.include_admins", "true"),
|
resource.TestCheckResourceAttr("github_branch_protection.master", "required_status_checks.0.include_admins", "true"),
|
||||||
resource.TestCheckResourceAttr("github_branch_protection.master", "required_status_checks.0.strict", "true"),
|
resource.TestCheckResourceAttr("github_branch_protection.master", "required_status_checks.0.strict", "true"),
|
||||||
|
@ -38,12 +42,12 @@ func TestAccGithubBranchProtection_basic(t *testing.T) {
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Config: testAccGithubBranchProtectionUpdateConfig,
|
Config: testAccGithubBranchProtectionUpdateConfig(repoName),
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccCheckGithubProtectedBranchExists("github_branch_protection.master", &protection),
|
testAccCheckGithubProtectedBranchExists("github_branch_protection.master", repoName+":master", &protection),
|
||||||
testAccCheckGithubBranchProtectionRequiredStatusChecks(&protection, false, false, []string{"github/bar"}),
|
testAccCheckGithubBranchProtectionRequiredStatusChecks(&protection, false, false, []string{"github/bar"}),
|
||||||
testAccCheckGithubBranchProtectionNoRestrictionsExist(&protection),
|
testAccCheckGithubBranchProtectionNoRestrictionsExist(&protection),
|
||||||
resource.TestCheckResourceAttr("github_branch_protection.master", "repository", testRepo),
|
resource.TestCheckResourceAttr("github_branch_protection.master", "repository", repoName),
|
||||||
resource.TestCheckResourceAttr("github_branch_protection.master", "branch", "master"),
|
resource.TestCheckResourceAttr("github_branch_protection.master", "branch", "master"),
|
||||||
resource.TestCheckResourceAttr("github_branch_protection.master", "required_status_checks.0.include_admins", "false"),
|
resource.TestCheckResourceAttr("github_branch_protection.master", "required_status_checks.0.include_admins", "false"),
|
||||||
resource.TestCheckResourceAttr("github_branch_protection.master", "required_status_checks.0.strict", "false"),
|
resource.TestCheckResourceAttr("github_branch_protection.master", "required_status_checks.0.strict", "false"),
|
||||||
|
@ -58,13 +62,15 @@ func TestAccGithubBranchProtection_basic(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestAccGithubBranchProtection_importBasic(t *testing.T) {
|
func TestAccGithubBranchProtection_importBasic(t *testing.T) {
|
||||||
|
rString := acctest.RandString(5)
|
||||||
|
|
||||||
resource.Test(t, resource.TestCase{
|
resource.Test(t, resource.TestCase{
|
||||||
PreCheck: func() { testAccPreCheck(t) },
|
PreCheck: func() { testAccPreCheck(t) },
|
||||||
Providers: testAccProviders,
|
Providers: testAccProviders,
|
||||||
CheckDestroy: testAccGithubBranchProtectionDestroy,
|
CheckDestroy: testAccGithubBranchProtectionDestroy,
|
||||||
Steps: []resource.TestStep{
|
Steps: []resource.TestStep{
|
||||||
{
|
{
|
||||||
Config: testAccGithubBranchProtectionConfig,
|
Config: testAccGithubBranchProtectionConfig(rString),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ResourceName: "github_branch_protection.master",
|
ResourceName: "github_branch_protection.master",
|
||||||
|
@ -75,15 +81,15 @@ func TestAccGithubBranchProtection_importBasic(t *testing.T) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func testAccCheckGithubProtectedBranchExists(n string, protection *github.Protection) resource.TestCheckFunc {
|
func testAccCheckGithubProtectedBranchExists(n, id string, protection *github.Protection) resource.TestCheckFunc {
|
||||||
return func(s *terraform.State) error {
|
return func(s *terraform.State) error {
|
||||||
rs, ok := s.RootModule().Resources[n]
|
rs, ok := s.RootModule().Resources[n]
|
||||||
if !ok {
|
if !ok {
|
||||||
return fmt.Errorf("Not Found: %s", n)
|
return fmt.Errorf("Not Found: %s", n)
|
||||||
}
|
}
|
||||||
|
|
||||||
if rs.Primary.ID != "test-repo:master" {
|
if rs.Primary.ID != id {
|
||||||
return fmt.Errorf("Expected ID to be %v, got %v", "test-repo:master", rs.Primary.ID)
|
return fmt.Errorf("Expected ID to be %v, got %v", id, rs.Primary.ID)
|
||||||
}
|
}
|
||||||
|
|
||||||
conn := testAccProvider.Meta().(*Organization).client
|
conn := testAccProvider.Meta().(*Organization).client
|
||||||
|
@ -185,9 +191,16 @@ func testAccGithubBranchProtectionDestroy(s *terraform.State) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var testAccGithubBranchProtectionConfig string = fmt.Sprintf(`
|
func testAccGithubBranchProtectionConfig(repoName string) string {
|
||||||
|
return fmt.Sprintf(`
|
||||||
|
resource "github_repository" "test" {
|
||||||
|
name = "%s"
|
||||||
|
description = "Terraform Acceptance Test %s"
|
||||||
|
auto_init = true
|
||||||
|
}
|
||||||
|
|
||||||
resource "github_branch_protection" "master" {
|
resource "github_branch_protection" "master" {
|
||||||
repository = "%s"
|
repository = "${github_repository.test.name}"
|
||||||
branch = "master"
|
branch = "master"
|
||||||
|
|
||||||
required_status_checks = {
|
required_status_checks = {
|
||||||
|
@ -204,11 +217,19 @@ resource "github_branch_protection" "master" {
|
||||||
users = ["%s"]
|
users = ["%s"]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
`, testRepo, testUser)
|
`, repoName, repoName, testUser)
|
||||||
|
}
|
||||||
|
|
||||||
|
func testAccGithubBranchProtectionUpdateConfig(repoName string) string {
|
||||||
|
return fmt.Sprintf(`
|
||||||
|
resource "github_repository" "test" {
|
||||||
|
name = "%s"
|
||||||
|
description = "Terraform Acceptance Test %s"
|
||||||
|
auto_init = true
|
||||||
|
}
|
||||||
|
|
||||||
var testAccGithubBranchProtectionUpdateConfig string = fmt.Sprintf(`
|
|
||||||
resource "github_branch_protection" "master" {
|
resource "github_branch_protection" "master" {
|
||||||
repository = "%s"
|
repository = "${github_repository.test.name}"
|
||||||
branch = "master"
|
branch = "master"
|
||||||
|
|
||||||
required_status_checks = {
|
required_status_checks = {
|
||||||
|
@ -217,4 +238,5 @@ resource "github_branch_protection" "master" {
|
||||||
contexts = ["github/bar"]
|
contexts = ["github/bar"]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
`, testRepo)
|
`, repoName, repoName)
|
||||||
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/google/go-github/github"
|
"github.com/google/go-github/github"
|
||||||
|
"github.com/hashicorp/terraform/helper/acctest"
|
||||||
"github.com/hashicorp/terraform/helper/resource"
|
"github.com/hashicorp/terraform/helper/resource"
|
||||||
"github.com/hashicorp/terraform/terraform"
|
"github.com/hashicorp/terraform/terraform"
|
||||||
)
|
)
|
||||||
|
@ -13,27 +14,45 @@ import (
|
||||||
func TestAccGithubIssueLabel_basic(t *testing.T) {
|
func TestAccGithubIssueLabel_basic(t *testing.T) {
|
||||||
var label github.Label
|
var label github.Label
|
||||||
|
|
||||||
|
rString := acctest.RandString(5)
|
||||||
|
repoName := fmt.Sprintf("tf-acc-test-branch-issue-label-%s", rString)
|
||||||
|
|
||||||
resource.Test(t, resource.TestCase{
|
resource.Test(t, resource.TestCase{
|
||||||
PreCheck: func() { testAccPreCheck(t) },
|
PreCheck: func() { testAccPreCheck(t) },
|
||||||
Providers: testAccProviders,
|
Providers: testAccProviders,
|
||||||
CheckDestroy: testAccGithubIssueLabelDestroy,
|
CheckDestroy: testAccGithubIssueLabelDestroy,
|
||||||
Steps: []resource.TestStep{
|
Steps: []resource.TestStep{
|
||||||
{
|
{
|
||||||
Config: testAccGithubIssueLabelConfig,
|
Config: testAccGithubIssueLabelConfig(repoName),
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccCheckGithubIssueLabelExists("github_issue_label.test", &label),
|
testAccCheckGithubIssueLabelExists("github_issue_label.test", &label),
|
||||||
testAccCheckGithubIssueLabelAttributes(&label, "foo", "000000"),
|
testAccCheckGithubIssueLabelAttributes(&label, "foo", "000000"),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Config: testAccGithubIssueLabelUpdateConfig,
|
Config: testAccGithubIssueLabelUpdateConfig(repoName),
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccCheckGithubIssueLabelExists("github_issue_label.test", &label),
|
testAccCheckGithubIssueLabelExists("github_issue_label.test", &label),
|
||||||
testAccCheckGithubIssueLabelAttributes(&label, "bar", "FFFFFF"),
|
testAccCheckGithubIssueLabelAttributes(&label, "bar", "FFFFFF"),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestAccGithubIssueLabel_existingLabel(t *testing.T) {
|
||||||
|
var label github.Label
|
||||||
|
|
||||||
|
rString := acctest.RandString(5)
|
||||||
|
repoName := fmt.Sprintf("tf-acc-test-branch-issue-label-%s", rString)
|
||||||
|
|
||||||
|
resource.Test(t, resource.TestCase{
|
||||||
|
PreCheck: func() { testAccPreCheck(t) },
|
||||||
|
Providers: testAccProviders,
|
||||||
|
CheckDestroy: testAccGithubIssueLabelDestroy,
|
||||||
|
Steps: []resource.TestStep{
|
||||||
{
|
{
|
||||||
Config: testAccGitHubIssueLabelExistsConfig,
|
Config: testAccGitHubIssueLabelExistsConfig(repoName),
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccCheckGithubIssueLabelExists("github_issue_label.test", &label),
|
testAccCheckGithubIssueLabelExists("github_issue_label.test", &label),
|
||||||
testAccCheckGithubIssueLabelAttributes(&label, "enhancement", "FF00FF"),
|
testAccCheckGithubIssueLabelAttributes(&label, "enhancement", "FF00FF"),
|
||||||
|
@ -44,13 +63,16 @@ func TestAccGithubIssueLabel_basic(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestAccGithubIssueLabel_importBasic(t *testing.T) {
|
func TestAccGithubIssueLabel_importBasic(t *testing.T) {
|
||||||
|
rString := acctest.RandString(5)
|
||||||
|
repoName := fmt.Sprintf("tf-acc-test-branch-issue-label-%s", rString)
|
||||||
|
|
||||||
resource.Test(t, resource.TestCase{
|
resource.Test(t, resource.TestCase{
|
||||||
PreCheck: func() { testAccPreCheck(t) },
|
PreCheck: func() { testAccPreCheck(t) },
|
||||||
Providers: testAccProviders,
|
Providers: testAccProviders,
|
||||||
CheckDestroy: testAccGithubIssueLabelDestroy,
|
CheckDestroy: testAccGithubIssueLabelDestroy,
|
||||||
Steps: []resource.TestStep{
|
Steps: []resource.TestStep{
|
||||||
{
|
{
|
||||||
Config: testAccGithubIssueLabelConfig,
|
Config: testAccGithubIssueLabelConfig(repoName),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ResourceName: "github_issue_label.test",
|
ResourceName: "github_issue_label.test",
|
||||||
|
@ -126,26 +148,39 @@ func testAccGithubIssueLabelDestroy(s *terraform.State) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var testAccGithubIssueLabelConfig string = fmt.Sprintf(`
|
func testAccGithubIssueLabelConfig(repoName string) string {
|
||||||
|
return fmt.Sprintf(`
|
||||||
|
resource "github_repository" "test" {
|
||||||
|
name = "%s"
|
||||||
|
}
|
||||||
|
|
||||||
resource "github_issue_label" "test" {
|
resource "github_issue_label" "test" {
|
||||||
repository = "%s"
|
repository = "${github_repository.test.name}"
|
||||||
name = "foo"
|
name = "foo"
|
||||||
color = "000000"
|
color = "000000"
|
||||||
}
|
}
|
||||||
`, testRepo)
|
`, repoName)
|
||||||
|
}
|
||||||
|
|
||||||
|
func testAccGithubIssueLabelUpdateConfig(repoName string) string {
|
||||||
|
return fmt.Sprintf(`
|
||||||
|
resource "github_repository" "test" {
|
||||||
|
name = "%s"
|
||||||
|
}
|
||||||
|
|
||||||
var testAccGithubIssueLabelUpdateConfig string = fmt.Sprintf(`
|
|
||||||
resource "github_issue_label" "test" {
|
resource "github_issue_label" "test" {
|
||||||
repository = "%s"
|
repository = "${github_repository.test.name}"
|
||||||
name = "bar"
|
name = "bar"
|
||||||
color = "FFFFFF"
|
color = "FFFFFF"
|
||||||
}
|
}
|
||||||
`, testRepo)
|
`, repoName)
|
||||||
|
}
|
||||||
|
|
||||||
var testAccGitHubIssueLabelExistsConfig string = fmt.Sprintf(`
|
func testAccGitHubIssueLabelExistsConfig(repoName string) string {
|
||||||
|
return fmt.Sprintf(`
|
||||||
// Create a repository which has the default labels
|
// Create a repository which has the default labels
|
||||||
resource "github_repository" "test" {
|
resource "github_repository" "test" {
|
||||||
name = "tf-acc-repo-label-abc1234"
|
name = "%s"
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "github_issue_label" "test" {
|
resource "github_issue_label" "test" {
|
||||||
|
@ -153,4 +188,5 @@ resource "github_issue_label" "test" {
|
||||||
name = "enhancement" // Important! This is a pre-created label
|
name = "enhancement" // Important! This is a pre-created label
|
||||||
color = "FF00FF"
|
color = "FF00FF"
|
||||||
}
|
}
|
||||||
`)
|
`, repoName)
|
||||||
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/hashicorp/terraform/helper/acctest"
|
||||||
"github.com/hashicorp/terraform/helper/resource"
|
"github.com/hashicorp/terraform/helper/resource"
|
||||||
"github.com/hashicorp/terraform/terraform"
|
"github.com/hashicorp/terraform/terraform"
|
||||||
)
|
)
|
||||||
|
@ -12,13 +13,15 @@ import (
|
||||||
const expectedPermission string = "admin"
|
const expectedPermission string = "admin"
|
||||||
|
|
||||||
func TestAccGithubRepositoryCollaborator_basic(t *testing.T) {
|
func TestAccGithubRepositoryCollaborator_basic(t *testing.T) {
|
||||||
|
repoName := fmt.Sprintf("tf-acc-test-collab-%s", acctest.RandString(5))
|
||||||
|
|
||||||
resource.Test(t, resource.TestCase{
|
resource.Test(t, resource.TestCase{
|
||||||
PreCheck: func() { testAccPreCheck(t) },
|
PreCheck: func() { testAccPreCheck(t) },
|
||||||
Providers: testAccProviders,
|
Providers: testAccProviders,
|
||||||
CheckDestroy: testAccCheckGithubRepositoryCollaboratorDestroy,
|
CheckDestroy: testAccCheckGithubRepositoryCollaboratorDestroy,
|
||||||
Steps: []resource.TestStep{
|
Steps: []resource.TestStep{
|
||||||
{
|
{
|
||||||
Config: testAccGithubRepositoryCollaboratorConfig,
|
Config: testAccGithubRepositoryCollaboratorConfig(repoName),
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccCheckGithubRepositoryCollaboratorExists("github_repository_collaborator.test_repo_collaborator"),
|
testAccCheckGithubRepositoryCollaboratorExists("github_repository_collaborator.test_repo_collaborator"),
|
||||||
testAccCheckGithubRepositoryCollaboratorPermission("github_repository_collaborator.test_repo_collaborator"),
|
testAccCheckGithubRepositoryCollaboratorPermission("github_repository_collaborator.test_repo_collaborator"),
|
||||||
|
@ -29,13 +32,15 @@ func TestAccGithubRepositoryCollaborator_basic(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestAccGithubRepositoryCollaborator_importBasic(t *testing.T) {
|
func TestAccGithubRepositoryCollaborator_importBasic(t *testing.T) {
|
||||||
|
repoName := fmt.Sprintf("tf-acc-test-collab-%s", acctest.RandString(5))
|
||||||
|
|
||||||
resource.Test(t, resource.TestCase{
|
resource.Test(t, resource.TestCase{
|
||||||
PreCheck: func() { testAccPreCheck(t) },
|
PreCheck: func() { testAccPreCheck(t) },
|
||||||
Providers: testAccProviders,
|
Providers: testAccProviders,
|
||||||
CheckDestroy: testAccCheckGithubRepositoryCollaboratorDestroy,
|
CheckDestroy: testAccCheckGithubRepositoryCollaboratorDestroy,
|
||||||
Steps: []resource.TestStep{
|
Steps: []resource.TestStep{
|
||||||
{
|
{
|
||||||
Config: testAccGithubRepositoryCollaboratorConfig,
|
Config: testAccGithubRepositoryCollaboratorConfig(repoName),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ResourceName: "github_repository_collaborator.test_repo_collaborator",
|
ResourceName: "github_repository_collaborator.test_repo_collaborator",
|
||||||
|
@ -148,10 +153,16 @@ func testAccCheckGithubRepositoryCollaboratorPermission(n string) resource.TestC
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var testAccGithubRepositoryCollaboratorConfig string = fmt.Sprintf(`
|
func testAccGithubRepositoryCollaboratorConfig(repoName string) string {
|
||||||
|
return fmt.Sprintf(`
|
||||||
|
resource "github_repository" "test" {
|
||||||
|
name = "%s"
|
||||||
|
}
|
||||||
|
|
||||||
resource "github_repository_collaborator" "test_repo_collaborator" {
|
resource "github_repository_collaborator" "test_repo_collaborator" {
|
||||||
repository = "%s"
|
repository = "${github_repository.test.name}"
|
||||||
username = "%s"
|
username = "%s"
|
||||||
permission = "%s"
|
permission = "%s"
|
||||||
}
|
}
|
||||||
`, testRepo, testCollaborator, expectedPermission)
|
`, repoName, testCollaborator, expectedPermission)
|
||||||
|
}
|
||||||
|
|
|
@ -13,7 +13,9 @@ import (
|
||||||
|
|
||||||
func TestAccGithubTeamRepository_basic(t *testing.T) {
|
func TestAccGithubTeamRepository_basic(t *testing.T) {
|
||||||
var repository github.Repository
|
var repository github.Repository
|
||||||
|
|
||||||
randString := acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)
|
randString := acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)
|
||||||
|
repoName := fmt.Sprintf("tf-acc-test-team-%s", acctest.RandString(5))
|
||||||
|
|
||||||
resource.Test(t, resource.TestCase{
|
resource.Test(t, resource.TestCase{
|
||||||
PreCheck: func() { testAccPreCheck(t) },
|
PreCheck: func() { testAccPreCheck(t) },
|
||||||
|
@ -21,14 +23,14 @@ func TestAccGithubTeamRepository_basic(t *testing.T) {
|
||||||
CheckDestroy: testAccCheckGithubTeamRepositoryDestroy,
|
CheckDestroy: testAccCheckGithubTeamRepositoryDestroy,
|
||||||
Steps: []resource.TestStep{
|
Steps: []resource.TestStep{
|
||||||
{
|
{
|
||||||
Config: testAccGithubTeamRepositoryConfig(randString, testRepo),
|
Config: testAccGithubTeamRepositoryConfig(randString, repoName),
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccCheckGithubTeamRepositoryExists("github_team_repository.test_team_test_repo", &repository),
|
testAccCheckGithubTeamRepositoryExists("github_team_repository.test_team_test_repo", &repository),
|
||||||
testAccCheckGithubTeamRepositoryRoleState("pull", &repository),
|
testAccCheckGithubTeamRepositoryRoleState("pull", &repository),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Config: testAccGithubTeamRepositoryUpdateConfig(randString, testRepo),
|
Config: testAccGithubTeamRepositoryUpdateConfig(randString, repoName),
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccCheckGithubTeamRepositoryExists("github_team_repository.test_team_test_repo", &repository),
|
testAccCheckGithubTeamRepositoryExists("github_team_repository.test_team_test_repo", &repository),
|
||||||
testAccCheckGithubTeamRepositoryRoleState("push", &repository),
|
testAccCheckGithubTeamRepositoryRoleState("push", &repository),
|
||||||
|
@ -40,6 +42,7 @@ func TestAccGithubTeamRepository_basic(t *testing.T) {
|
||||||
|
|
||||||
func TestAccGithubTeamRepository_importBasic(t *testing.T) {
|
func TestAccGithubTeamRepository_importBasic(t *testing.T) {
|
||||||
randString := acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)
|
randString := acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)
|
||||||
|
repoName := fmt.Sprintf("tf-acc-test-team-%s", acctest.RandString(5))
|
||||||
|
|
||||||
resource.Test(t, resource.TestCase{
|
resource.Test(t, resource.TestCase{
|
||||||
PreCheck: func() { testAccPreCheck(t) },
|
PreCheck: func() { testAccPreCheck(t) },
|
||||||
|
@ -47,7 +50,7 @@ func TestAccGithubTeamRepository_importBasic(t *testing.T) {
|
||||||
CheckDestroy: testAccCheckGithubTeamRepositoryDestroy,
|
CheckDestroy: testAccCheckGithubTeamRepositoryDestroy,
|
||||||
Steps: []resource.TestStep{
|
Steps: []resource.TestStep{
|
||||||
{
|
{
|
||||||
Config: testAccGithubTeamRepositoryConfig(randString, testRepo),
|
Config: testAccGithubTeamRepositoryConfig(randString, repoName),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ResourceName: "github_team_repository.test_team_test_repo",
|
ResourceName: "github_team_repository.test_team_test_repo",
|
||||||
|
@ -159,9 +162,13 @@ resource "github_team" "test_team" {
|
||||||
description = "Terraform acc test group"
|
description = "Terraform acc test group"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
resource "github_repository" "test" {
|
||||||
|
name = "%s"
|
||||||
|
}
|
||||||
|
|
||||||
resource "github_team_repository" "test_team_test_repo" {
|
resource "github_team_repository" "test_team_test_repo" {
|
||||||
team_id = "${github_team.test_team.id}"
|
team_id = "${github_team.test_team.id}"
|
||||||
repository = "%s"
|
repository = "${github_repository.test.name}"
|
||||||
permission = "pull"
|
permission = "pull"
|
||||||
}
|
}
|
||||||
`, randString, repoName)
|
`, randString, repoName)
|
||||||
|
@ -174,9 +181,13 @@ resource "github_team" "test_team" {
|
||||||
description = "Terraform acc test group"
|
description = "Terraform acc test group"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
resource "github_repository" "test" {
|
||||||
|
name = "%s"
|
||||||
|
}
|
||||||
|
|
||||||
resource "github_team_repository" "test_team_test_repo" {
|
resource "github_team_repository" "test_team_test_repo" {
|
||||||
team_id = "${github_team.test_team.id}"
|
team_id = "${github_team.test_team.id}"
|
||||||
repository = "%s"
|
repository = "${github_repository.test.name}"
|
||||||
permission = "push"
|
permission = "push"
|
||||||
}
|
}
|
||||||
`, randString, repoName)
|
`, randString, repoName)
|
||||||
|
|
Loading…
Reference in New Issue