Skip to content

Commit 3d20b63

Browse files
committed
Fix faulty test
Signed-off-by: Timo Sand <[email protected]>
1 parent 739ac70 commit 3d20b63

1 file changed

Lines changed: 12 additions & 29 deletions

File tree

github/resource_github_repository_test.go

Lines changed: 12 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1168,48 +1168,31 @@ resource "github_repository" "test" {
11681168
})
11691169
})
11701170

1171-
t.Run("updates repos to public visibility", func(t *testing.T) {
1171+
t.Run("updates_repos_to_public_visibility", func(t *testing.T) {
11721172
randomID := acctest.RandStringFromCharSet(5, acctest.CharSetAlphaNum)
11731173
testRepoName := fmt.Sprintf("%spublic-vuln-%s", testResourcePrefix, randomID)
1174-
config := fmt.Sprintf(`
1174+
config := `
11751175
resource "github_repository" "test" {
11761176
name = "%s"
1177-
visibility = "private"
1177+
visibility = "%s"
11781178
}
1179-
`, testRepoName)
1180-
1181-
checks := map[string]resource.TestCheckFunc{
1182-
"before": resource.ComposeTestCheckFunc(
1183-
resource.TestCheckResourceAttr(
1184-
"github_repository.test", "vulnerability_alerts",
1185-
"false",
1186-
),
1187-
),
1188-
"after": resource.ComposeTestCheckFunc(
1189-
resource.TestCheckResourceAttr(
1190-
"github_repository.test", "vulnerability_alerts",
1191-
"true",
1192-
),
1193-
resource.TestCheckResourceAttr(
1194-
"github_repository.test", "visibility",
1195-
"private",
1196-
),
1197-
),
1198-
}
1179+
`
11991180

12001181
resource.Test(t, resource.TestCase{
12011182
PreCheck: func() { skipUnauthenticated(t) },
12021183
ProviderFactories: providerFactories,
12031184
Steps: []resource.TestStep{
12041185
{
1205-
Config: config,
1206-
Check: checks["before"],
1186+
Config: fmt.Sprintf(config, testRepoName, "private"),
1187+
Check: resource.ComposeTestCheckFunc(
1188+
resource.TestCheckResourceAttr("github_repository.test", "visibility", "private"),
1189+
),
12071190
},
12081191
{
1209-
Config: strings.Replace(config,
1210-
`}`,
1211-
"vulnerability_alerts = true\n}", 1),
1212-
Check: checks["after"],
1192+
Config: fmt.Sprintf(config, testRepoName, "public"),
1193+
Check: resource.ComposeTestCheckFunc(
1194+
resource.TestCheckResourceAttr("github_repository.test", "visibility", "public"),
1195+
),
12131196
},
12141197
},
12151198
})

0 commit comments

Comments
 (0)