@@ -16,6 +16,10 @@ import (
1616)
1717
1818func TestAccGithubRepository (t * testing.T ) {
19+ baseVisibility := "public"
20+ if testAccConf .authMode == enterprise {
21+ baseVisibility = "private" // Enable tests to run on GHEC EMU
22+ }
1923 t .Run ("creates and updates repositories without error" , func (t * testing.T ) {
2024 randomID := acctest .RandStringFromCharSet (5 , acctest .CharSetAlphaNum )
2125 testRepoName := fmt .Sprintf ("%screate-%s" , testResourcePrefix , randomID )
@@ -169,8 +173,9 @@ func TestAccGithubRepository(t *testing.T) {
169173 name = "%s"
170174 description = "Terraform acceptance tests %[1]s"
171175 archived = false
176+ visibility = "%s"
172177 }
173- ` , testRepoName )
178+ ` , testRepoName , baseVisibility )
174179
175180 checks := map [string ]resource.TestCheckFunc {
176181 "before" : resource .ComposeTestCheckFunc (
@@ -205,6 +210,35 @@ func TestAccGithubRepository(t *testing.T) {
205210 })
206211 })
207212
213+ t .Run ("creates and archives repositories without error" , func (t * testing.T ) {
214+ randomID := acctest .RandStringFromCharSet (5 , acctest .CharSetAlphaNum )
215+ testRepoName := fmt .Sprintf ("%screate-and-archive-%s" , testResourcePrefix , randomID )
216+ config := fmt .Sprintf (`
217+ resource "github_repository" "test" {
218+ name = "%s"
219+ description = "Terraform acceptance tests %[1]s"
220+ archived = true
221+ visibility = "%s"
222+ }
223+ ` , testRepoName , baseVisibility )
224+
225+ resource .Test (t , resource.TestCase {
226+ PreCheck : func () { skipUnauthenticated (t ) },
227+ ProviderFactories : providerFactories ,
228+ Steps : []resource.TestStep {
229+ {
230+ Config : config ,
231+ Check : resource .ComposeTestCheckFunc (
232+ resource .TestCheckResourceAttr (
233+ "github_repository.test" , "archived" ,
234+ "true" ,
235+ ),
236+ ),
237+ },
238+ },
239+ })
240+ })
241+
208242 t .Run ("manages the project feature for a repository" , func (t * testing.T ) {
209243 randomID := acctest .RandStringFromCharSet (5 , acctest .CharSetAlphaNum )
210244 testRepoName := fmt .Sprintf ("%sproject-%s" , testResourcePrefix , randomID )
0 commit comments