@@ -675,6 +675,95 @@ func TestGithubRepositoryRulesets(t *testing.T) {
675675
676676 })
677677
678+ t .Run ("Updates ruleset without bypass actors defined" , func (t * testing.T ) {
679+
680+ config := fmt .Sprintf (`
681+ resource "github_repository" "test" {
682+ name = "tf-acc-test-no-bypass-%s"
683+ description = "Terraform acceptance tests %[1]s"
684+ auto_init = true
685+ }
686+
687+ resource "github_repository_ruleset" "test" {
688+ name = "test-no-bypass"
689+ repository = github_repository.test.id
690+ target = "branch"
691+ enforcement = "active"
692+
693+ conditions {
694+ ref_name {
695+ include = ["~ALL"]
696+ exclude = []
697+ }
698+ }
699+
700+ rules {
701+ deletion = true
702+ }
703+ }
704+ ` , randomID )
705+
706+ configUpdated := strings .Replace (
707+ config ,
708+ "deletion = true" ,
709+ "deletion = false" ,
710+ 1 ,
711+ )
712+
713+ checks := map [string ]resource.TestCheckFunc {
714+ "before" : resource .ComposeTestCheckFunc (
715+ resource .TestCheckResourceAttr (
716+ "github_repository_ruleset.test" , "rules.0.deletion" ,
717+ "true" ,
718+ ),
719+ resource .TestCheckResourceAttr (
720+ "github_repository_ruleset.test" , "bypass_actors.#" ,
721+ "0" ,
722+ ),
723+ ),
724+ "after" : resource .ComposeTestCheckFunc (
725+ resource .TestCheckResourceAttr (
726+ "github_repository_ruleset.test" , "rules.0.deletion" ,
727+ "false" ,
728+ ),
729+ resource .TestCheckResourceAttr (
730+ "github_repository_ruleset.test" , "bypass_actors.#" ,
731+ "0" ,
732+ ),
733+ ),
734+ }
735+
736+ testCase := func (t * testing.T , mode string ) {
737+ resource .Test (t , resource.TestCase {
738+ PreCheck : func () { skipUnlessMode (t , mode ) },
739+ Providers : testAccProviders ,
740+ Steps : []resource.TestStep {
741+ {
742+ Config : config ,
743+ Check : checks ["before" ],
744+ },
745+ {
746+ Config : configUpdated ,
747+ Check : checks ["after" ],
748+ },
749+ },
750+ })
751+ }
752+
753+ t .Run ("with an anonymous account" , func (t * testing.T ) {
754+ t .Skip ("anonymous account not supported for this operation" )
755+ })
756+
757+ t .Run ("with an individual account" , func (t * testing.T ) {
758+ testCase (t , individual )
759+ })
760+
761+ t .Run ("with an organization account" , func (t * testing.T ) {
762+ testCase (t , organization )
763+ })
764+
765+ })
766+
678767 t .Run ("Creates repository ruleset with all bypass_modes" , func (t * testing.T ) {
679768
680769 config := fmt .Sprintf (`
0 commit comments