Skip to content

Commit 7915746

Browse files
committed
add acceptance tests for erroring on key prefix ending with number
1 parent cd0bd2d commit 7915746

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

github/resource_github_repository_autolink_reference_test.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,35 @@ func TestAccGithubRepositoryAutolinkReference(t *testing.T) {
268268
})
269269
})
270270

271+
t.Run("errors when key_prefix ends with a number", func(t *testing.T) {
272+
randomID := acctest.RandStringFromCharSet(5, acctest.CharSetAlphaNum)
273+
repoName := fmt.Sprintf("%srepo-autolink-%s", testResourcePrefix, randomID)
274+
config := fmt.Sprintf(`
275+
resource "github_repository" "test" {
276+
name = "%s"
277+
description = "Test autolink creation"
278+
}
279+
280+
resource "github_repository_autolink_reference" "autolink_invalid" {
281+
repository = github_repository.test.name
282+
283+
key_prefix = "TEST-1"
284+
target_url_template = "https://example.com/TEST-<num>"
285+
}
286+
`, repoName)
287+
288+
resource.Test(t, resource.TestCase{
289+
PreCheck: func() { skipUnauthenticated(t) },
290+
ProviderFactories: providerFactories,
291+
Steps: []resource.TestStep{
292+
{
293+
Config: config,
294+
ExpectError: regexp.MustCompile(`must not end with a number`),
295+
},
296+
},
297+
})
298+
})
299+
271300
t.Run("deletes repository autolink reference without error", func(t *testing.T) {
272301
randomID := acctest.RandStringFromCharSet(5, acctest.CharSetAlphaNum)
273302
repoName := fmt.Sprintf("%srepo-autolink-%s", testResourcePrefix, randomID)

0 commit comments

Comments
 (0)