@@ -491,3 +491,50 @@ func TestAllPushRulesWithUnknownRules(t *testing.T) {
491491 t .Error ("Unknown rule type should not appear in flattened rules to avoid causing diffs" )
492492 }
493493}
494+
495+ func TestCopilotCodeReviewRoundTrip (t * testing.T ) {
496+ // Test that copilot_code_review rule survives expand -> flatten round trip
497+ rulesMap := map [string ]any {
498+ "copilot_code_review" : []any {
499+ map [string ]any {
500+ "review_new_pushes" : true ,
501+ "review_draft_pull_requests" : false ,
502+ },
503+ },
504+ }
505+
506+ input := []any {rulesMap }
507+
508+ // Expand to GitHub API format
509+ expandedRules := expandRules (input , false )
510+
511+ if len (expandedRules ) != 1 {
512+ t .Fatalf ("Expected 1 expanded rule, got %d" , len (expandedRules ))
513+ }
514+
515+ if expandedRules [0 ].Type != "copilot_code_review" {
516+ t .Errorf ("Expected rule type copilot_code_review, got %s" , expandedRules [0 ].Type )
517+ }
518+
519+ // Flatten back to terraform format
520+ flattenedResult := flattenRules (expandedRules , false )
521+
522+ if len (flattenedResult ) != 1 {
523+ t .Fatalf ("Expected 1 flattened result, got %d" , len (flattenedResult ))
524+ }
525+
526+ flattenedRulesMap := flattenedResult [0 ].(map [string ]any )
527+ copilotRules := flattenedRulesMap ["copilot_code_review" ].([]map [string ]any )
528+
529+ if len (copilotRules ) != 1 {
530+ t .Fatalf ("Expected 1 copilot_code_review rule after round trip, got %d" , len (copilotRules ))
531+ }
532+
533+ if copilotRules [0 ]["review_new_pushes" ] != true {
534+ t .Errorf ("Expected review_new_pushes to be true, got %v" , copilotRules [0 ]["review_new_pushes" ])
535+ }
536+
537+ if copilotRules [0 ]["review_draft_pull_requests" ] != false {
538+ t .Errorf ("Expected review_draft_pull_requests to be false, got %v" , copilotRules [0 ]["review_draft_pull_requests" ])
539+ }
540+ }
0 commit comments