Skip to content

Commit d3c28ee

Browse files
committed
test(enterprise_ruleset): add test for conflicting repository conditions with property validation
1 parent 7fb3bfe commit d3c28ee

1 file changed

Lines changed: 51 additions & 0 deletions

File tree

github/resource_github_enterprise_ruleset_test.go

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package github
22

33
import (
44
"fmt"
5+
"regexp"
56
"testing"
67

78
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest"
@@ -841,3 +842,53 @@ func importEnterpriseRulesetByResourcePath(rulesetLogicalName string) resource.I
841842
return fmt.Sprintf("%s:%s", enterpriseSlug, rulesetID), nil
842843
}
843844
}
845+
846+
func TestAccGithubEnterpriseRuleset_conflictingRepositoryConditions(t *testing.T) {
847+
config := fmt.Sprintf(`
848+
resource "github_enterprise_ruleset" "test" {
849+
enterprise_slug = "%s"
850+
name = "%s-conflict-test"
851+
target = "branch"
852+
enforcement = "active"
853+
854+
conditions {
855+
organization_name {
856+
include = ["~ALL"]
857+
exclude = []
858+
}
859+
860+
repository_name {
861+
include = ["~ALL"]
862+
exclude = []
863+
}
864+
865+
repository_property {
866+
include {
867+
name = "language"
868+
property_values = ["Go"]
869+
}
870+
}
871+
872+
ref_name {
873+
include = ["~ALL"]
874+
exclude = []
875+
}
876+
}
877+
878+
rules {
879+
creation = true
880+
}
881+
}
882+
`, testAccConf.enterpriseSlug, testResourcePrefix)
883+
884+
resource.Test(t, resource.TestCase{
885+
PreCheck: func() { skipUnlessEnterprise(t) },
886+
ProviderFactories: providerFactories,
887+
Steps: []resource.TestStep{
888+
{
889+
Config: config,
890+
ExpectError: regexp.MustCompile(`"conditions.0.repository_name": only one of`),
891+
},
892+
},
893+
})
894+
}

0 commit comments

Comments
 (0)