Skip to content

Commit

Permalink
Bug Fix: import github_repository (#237)
Browse files Browse the repository at this point in the history
  • Loading branch information
megan07 authored Jun 10, 2019
1 parent dffe362 commit 79fac37
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
1 change: 1 addition & 0 deletions github/resource_github_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ func resourceGithubRepositoryRead(d *schema.ResourceData, meta interface{}) erro
d.Set("homepage_url", repo.Homepage)
d.Set("private", repo.Private)
d.Set("has_issues", repo.HasIssues)
d.Set("has_projects", repo.HasProjects)
d.Set("has_wiki", repo.HasWiki)
d.Set("allow_merge_commit", repo.AllowMergeCommit)
d.Set("allow_squash_merge", repo.AllowSquashMerge)
Expand Down
35 changes: 35 additions & 0 deletions github/resource_github_repository_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,29 @@ func TestAccGithubRepository_importBasic(t *testing.T) {
})
}

func TestAccGithubRepository_importHasProjects(t *testing.T) {
randString := acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckGithubRepositoryDestroy,
Steps: []resource.TestStep{
{
Config: testAccGithubRepositoryConfigHasProjects(randString),
},
{
ResourceName: "github_repository.foo",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{
"auto_init",
},
},
},
})
}

func TestAccGithubRepository_defaultBranch(t *testing.T) {
var repo github.Repository
randString := acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)
Expand Down Expand Up @@ -478,6 +501,9 @@ func testAccCheckGithubRepositoryAttributes(repo *github.Repository, want *testA
if *repo.HasIssues != want.HasIssues {
return fmt.Errorf("got has issues %#v; want %#v", *repo.HasIssues, want.HasIssues)
}
if *repo.HasProjects != want.HasProjects {
return fmt.Errorf("got has projects %#v; want %#v", *repo.HasProjects, want.HasProjects)
}
if *repo.HasWiki != want.HasWiki {
return fmt.Errorf("got has wiki %#v; want %#v", *repo.HasWiki, want.HasWiki)
}
Expand Down Expand Up @@ -643,6 +669,15 @@ resource "github_repository" "foo" {
`, randString, randString)
}

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

func testAccGithubRepositoryUpdateConfig(randString string) string {
return fmt.Sprintf(`
resource "github_repository" "foo" {
Expand Down

0 comments on commit 79fac37

Please sign in to comment.