@@ -296,4 +296,45 @@ func TestAccGithubBranchDefault(t *testing.T) {
296296 },
297297 })
298298 })
299+ t .Run ("regression_prevent_trying_rename_to_same_name" , func (t * testing.T ) {
300+ randomID := acctest .RandString (5 )
301+ repoName := fmt .Sprintf ("%sbranch-def-%s" , testResourcePrefix , randomID )
302+ config := `
303+ resource "github_repository" "test" {
304+ name = "%s"
305+ auto_init = true
306+ }
307+
308+ resource "github_branch_default" "test"{
309+ repository = github_repository.test.name
310+ branch = "development"
311+ rename = %t
312+ }
313+ `
314+
315+ resource .Test (t , resource.TestCase {
316+ PreCheck : func () { skipUnauthenticated (t ) },
317+ ProviderFactories : providerFactories ,
318+ Steps : []resource.TestStep {
319+ {
320+ Config : fmt .Sprintf (config , repoName , true ),
321+ ConfigStateChecks : []statecheck.StateCheck {
322+ statecheck .ExpectKnownValue ("github_branch_default.test" , tfjsonpath .New ("branch" ), knownvalue .StringExact ("development" )),
323+ },
324+ },
325+ {
326+ Config : fmt .Sprintf (config , repoName , false ),
327+ ConfigStateChecks : []statecheck.StateCheck {
328+ statecheck .ExpectKnownValue ("github_branch_default.test" , tfjsonpath .New ("branch" ), knownvalue .StringExact ("development" )),
329+ },
330+ },
331+ {
332+ Config : fmt .Sprintf (config , repoName , true ),
333+ ConfigStateChecks : []statecheck.StateCheck {
334+ statecheck .ExpectKnownValue ("github_branch_default.test" , tfjsonpath .New ("branch" ), knownvalue .StringExact ("development" )),
335+ },
336+ },
337+ },
338+ })
339+ })
299340}
0 commit comments