mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-25 18:45:20 -06:00
provider/github: Randomize repository collaborator acc tests
This commit is contained in:
parent
23bb27e5f5
commit
4041db698c
@ -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")
|
||||||
|
|
||||||
|
@ -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)
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user