Skip to content

Commit cd7bb22

Browse files
new test convention and use testResourcePrefix
1 parent ffa8f54 commit cd7bb22

1 file changed

Lines changed: 13 additions & 28 deletions

File tree

github/resource_github_repository_test.go

Lines changed: 13 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1314,9 +1314,11 @@ func Test_expandPages(t *testing.T) {
13141314
})
13151315

13161316
t.Run("manages private pages feature for a repository", func(t *testing.T) {
1317+
randomID := acctest.RandStringFromCharSet(5, acctest.CharSetAlphaNum)
1318+
testRepoName := fmt.Sprintf("%sprivate-pages-%s", testResourcePrefix, randomID)
13171319
config := fmt.Sprintf(`
13181320
resource "github_repository" "test" {
1319-
name = "tf-acc-%s"
1321+
name = "%s"
13201322
auto_init = true
13211323
pages {
13221324
source {
@@ -1325,38 +1327,21 @@ func Test_expandPages(t *testing.T) {
13251327
public = false
13261328
}
13271329
}
1328-
`, randomID)
1330+
`, testRepoName)
13291331

13301332
check := resource.ComposeTestCheckFunc(
1331-
resource.TestCheckResourceAttr(
1332-
"github_repository.test", "pages.0.public",
1333-
"false",
1334-
),
1333+
resource.TestCheckResourceAttr("github_repository.test", "pages.0.public", "false"),
13351334
)
13361335

1337-
testCase := func(t *testing.T, mode string) {
1338-
resource.Test(t, resource.TestCase{
1339-
PreCheck: func() { skipUnlessMode(t, mode) },
1340-
ProviderFactories: providerFactories,
1341-
Steps: []resource.TestStep{
1342-
{
1343-
Config: config,
1344-
Check: check,
1345-
},
1336+
resource.Test(t, resource.TestCase{
1337+
PreCheck: func() { skipUnlessMode(t, organization) },
1338+
ProviderFactories: providerFactories,
1339+
Steps: []resource.TestStep{
1340+
{
1341+
Config: config,
1342+
Check: check,
13461343
},
1347-
})
1348-
}
1349-
1350-
t.Run("with an anonymous account", func(t *testing.T) {
1351-
t.Skip("anonymous account not supported for this feature")
1352-
})
1353-
1354-
t.Run("with an individual account", func(t *testing.T) {
1355-
t.Skip("individual account not supported for this feature")
1356-
})
1357-
1358-
t.Run("with an organization account", func(t *testing.T) {
1359-
testCase(t, organization)
1344+
},
13601345
})
13611346
})
13621347
}

0 commit comments

Comments
 (0)