Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issues with auto_init destroying repositories #317

Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion github/resource_github_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func resourceGithubRepository() *schema.Resource {
"auto_init": {
Type: schema.TypeBool,
Optional: true,
ForceNew: true,
ForceNew: false,
majormoses marked this conversation as resolved.
Show resolved Hide resolved
majormoses marked this conversation as resolved.
Show resolved Hide resolved
},
"default_branch": {
Type: schema.TypeString,
Expand Down
67 changes: 0 additions & 67 deletions github/resource_github_repository_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -451,48 +451,6 @@ func TestAccGithubRepository_topics(t *testing.T) {
})
}

func TestAccGithubRepository_autoInitForceNew(t *testing.T) {
var repo github.Repository

rn := "github_repository.foo"
randString := acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)
name := fmt.Sprintf("tf-acc-test-%s", randString)

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckGithubRepositoryDestroy,
Steps: []resource.TestStep{
{
Config: testAccGithubRepositoryConfigAutoInitForceNew(randString),
Check: resource.ComposeTestCheckFunc(
testAccCheckGithubRepositoryExists(rn, &repo),
resource.TestCheckResourceAttr(rn, "name", name),
resource.TestCheckResourceAttr(rn, "auto_init", "false"),
),
},
{
Config: testAccGithubRepositoryConfigAutoInitForceNewUpdate(randString),
Check: resource.ComposeTestCheckFunc(
testAccCheckGithubRepositoryExists(rn, &repo),
resource.TestCheckResourceAttr(rn, "name", name),
resource.TestCheckResourceAttr(rn, "auto_init", "true"),
resource.TestCheckResourceAttr(rn, "license_template", "mpl-2.0"),
resource.TestCheckResourceAttr(rn, "gitignore_template", "Go"),
),
},
{
ResourceName: rn,
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{
"auto_init", "license_template", "gitignore_template",
},
},
},
})
}

func TestAccGithubRepository_createFromTemplate(t *testing.T) {
var repo github.Repository

Expand Down Expand Up @@ -940,28 +898,3 @@ resource "github_repository" "foo" {
}
`, randString, randString, topicList)
}

func testAccGithubRepositoryConfigAutoInitForceNew(randString string) string {
return fmt.Sprintf(`
resource "github_repository" "foo" {
name = "tf-acc-test-%s"
auto_init = false
}
`, randString)
}

func testAccGithubRepositoryConfigAutoInitForceNewUpdate(randString string) string {
return fmt.Sprintf(`
resource "github_repository" "foo" {
name = "tf-acc-test-%s"
auto_init = true
license_template = "mpl-2.0"
gitignore_template = "Go"
}

resource "github_branch_protection" "repo_name_master" {
repository = "${github_repository.foo.name}"
branch = "master"
}
`, randString)
}