diff --git a/builtin/providers/github/provider_test.go b/builtin/providers/github/provider_test.go index b227d52712..79924badf8 100644 --- a/builtin/providers/github/provider_test.go +++ b/builtin/providers/github/provider_test.go @@ -8,8 +8,6 @@ import ( "github.com/hashicorp/terraform/terraform" ) -const testRepo string = "test-repo" - var testUser string = os.Getenv("GITHUB_TEST_USER") var testCollaborator string = os.Getenv("GITHUB_TEST_COLLABORATOR") diff --git a/builtin/providers/github/resource_github_repository_collaborator_test.go b/builtin/providers/github/resource_github_repository_collaborator_test.go index 065cadeabd..c842bfe44f 100644 --- a/builtin/providers/github/resource_github_repository_collaborator_test.go +++ b/builtin/providers/github/resource_github_repository_collaborator_test.go @@ -5,6 +5,7 @@ import ( "fmt" "testing" + "github.com/hashicorp/terraform/helper/acctest" "github.com/hashicorp/terraform/helper/resource" "github.com/hashicorp/terraform/terraform" ) @@ -12,13 +13,15 @@ import ( const expectedPermission string = "admin" func TestAccGithubRepositoryCollaborator_basic(t *testing.T) { + repoName := fmt.Sprintf("tf-acc-test-collab-%s", acctest.RandString(5)) + resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, Providers: testAccProviders, CheckDestroy: testAccCheckGithubRepositoryCollaboratorDestroy, Steps: []resource.TestStep{ { - Config: testAccGithubRepositoryCollaboratorConfig, + Config: testAccGithubRepositoryCollaboratorConfig(repoName), Check: resource.ComposeTestCheckFunc( testAccCheckGithubRepositoryCollaboratorExists("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) { + repoName := fmt.Sprintf("tf-acc-test-collab-%s", acctest.RandString(5)) + resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, Providers: testAccProviders, CheckDestroy: testAccCheckGithubRepositoryCollaboratorDestroy, Steps: []resource.TestStep{ { - Config: testAccGithubRepositoryCollaboratorConfig, + Config: testAccGithubRepositoryCollaboratorConfig(repoName), }, { 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" { - repository = "%s" + repository = "${github_repository.test.name}" username = "%s" permission = "%s" } -`, testRepo, testCollaborator, expectedPermission) +`, repoName, testCollaborator, expectedPermission) +}