Skip to content

Commit

Permalink
archives repositories on destroy
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeremy Udit committed Sep 15, 2020
1 parent 9c7e340 commit 0878429
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/workflows/dotcom-acceptance-tests.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: Dotcom Acceptance Tests

on:
push:
pull_request:
types: [opened, synchronize, reopened]

Expand Down
59 changes: 59 additions & 0 deletions github/resource_github_repository_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,65 @@ func TestAccGithubRepositories(t *testing.T) {

})

t.Run("archives repositories on destroy", func(t *testing.T) {

config := fmt.Sprintf(`
resource "github_repository" "test" {
name = "tf-acc-test-%[1]s"
auto_init = true
archive_on_destroy = true
archived = false
}
`, randomID)

checks := map[string]resource.TestCheckFunc{
"before": resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(
"github_repository.test", "archived",
"false",
),
),
"after": resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(
"github_repository.test", "archived",
"true",
),
),
}

testCase := func(t *testing.T, mode string) {
resource.Test(t, resource.TestCase{
PreCheck: func() { skipUnlessMode(t, mode) },
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: config,
Check: checks["before"],
},
{
Config: strings.Replace(config,
`archived = false`,
`archived = true`, 1),
Check: checks["after"],
},
},
})
}

t.Run("with an anonymous account", func(t *testing.T) {
t.Skip("anonymous account not supported for this operation")
})

t.Run("with an individual account", func(t *testing.T) {
testCase(t, individual)
})

t.Run("with an organization account", func(t *testing.T) {
testCase(t, organization)
})

})

}

func testSweepRepositories(region string) error {
Expand Down

0 comments on commit 0878429

Please sign in to comment.