@@ -363,6 +363,67 @@ func TestGithubRepositoryRulesets(t *testing.T) {
363363 })
364364
365365 })
366+ t .Run ("Creates repository rulesets with paid features without errors" , func (t * testing.T ) {
367+ if isPaidPlan != "true" {
368+ t .Skip ("Skipping because `GITHUB_PAID_FEATURES` is not set to true" )
369+ }
370+ config := fmt .Sprintf (`
371+ resource "github_repository" "test" {
372+ name = "tf-acc-test-%s"
373+ auto_init = false
374+ visibility = "internal"
375+ vulnerability_alerts = true
376+ }
377+
378+ resource "github_repository_ruleset" "test_push" {
379+ name = "test-push"
380+ repository = github_repository.test.id
381+ target = "push"
382+ enforcement = "active"
383+
384+ rules {
385+ file_path_restriction {
386+ restricted_file_paths = ["test.txt"]
387+ }
388+ }
389+ }
390+ ` , randomID )
391+ check := resource .ComposeTestCheckFunc (
392+ resource .TestCheckResourceAttr (
393+ "github_repository_ruleset.test_push" , "name" ,
394+ "test-push" ,
395+ ),
396+ resource .TestCheckResourceAttr (
397+ "github_repository_ruleset.test_push" , "target" ,
398+ "push" ,
399+ ),
400+ resource .TestCheckResourceAttr (
401+ "github_repository_ruleset.test_push" , "rules.0.file_path_restriction.0.restricted_file_paths.0" ,
402+ "test.txt" ,
403+ ),
404+ )
405+ testCase := func (t * testing.T , mode string ) {
406+ resource .Test (t , resource.TestCase {
407+ PreCheck : func () { skipUnlessMode (t , mode ) },
408+ Providers : testAccProviders ,
409+ Steps : []resource.TestStep {
410+ {
411+ Config : config ,
412+ Check : check ,
413+ },
414+ },
415+ })
416+ }
417+ t .Run ("with an anonymous account" , func (t * testing.T ) {
418+ t .Skip ("anonymous account not supported for this operation" )
419+ })
420+ t .Run ("with an individual account" , func (t * testing.T ) {
421+ t .Skip ("individual account not supported for this operation" )
422+ })
423+ t .Run ("with a paid plan in an organization" , func (t * testing.T ) {
424+ testCase (t , organization )
425+ })
426+ })
366427
367428}
368429
0 commit comments