99 "go.yaml.in/yaml/v4"
1010)
1111
12- // TestAutoFixIntegration tests basic auto-fix functionality
1312func TestAutoFixIntegration (t * testing.T ) {
1413 spec := `
1514openapi: 3.0.0
@@ -47,17 +46,14 @@ info:
4746
4847 result := ApplyRulesToRuleSet (execution )
4948
50- // Should have fixed results
5149 assert .Greater (t , len (result .FixedResults ), 0 , "Should have fixed some violations" )
5250
53- // Fixed results should have AutoFixed flag set
5451 for _ , r := range result .FixedResults {
5552 assert .True (t , r .AutoFixed )
5653 assert .Equal (t , "empty-description-autofix" , r .RuleId )
5754 }
5855}
5956
60- // TestAutoFixDisabled tests that autofix doesn't run when disabled
6157func TestAutoFixDisabled (t * testing.T ) {
6258 spec := `
6359openapi: 3.0.0
@@ -81,13 +77,10 @@ info:
8177 }
8278
8379 result := ApplyRulesToRuleSet (execution )
84-
85- // Should have regular results, no fixed results
8680 assert .Greater (t , len (result .Results ), 0 )
8781 assert .Equal (t , 0 , len (result .FixedResults ))
8882}
8983
90- // TestAutoFixDoesNotAffectNonFixableViolations tests that autofix only affects fixable rules
9184func TestAutoFixDoesNotAffectNonFixableViolations (t * testing.T ) {
9285 spec := `
9386openapi: 3.0.0
@@ -140,17 +133,14 @@ paths:
140133
141134 result := ApplyRulesToRuleSet (execution )
142135
143- // Should have both fixed and unfixed results
144136 assert .Greater (t , len (result .FixedResults ), 0 , "Should have fixed some violations" )
145137 assert .Greater (t , len (result .Results ), 0 , "Should have unfixed violations" )
146138
147- // Verify fixed results are only from fixable rule
148139 for _ , r := range result .FixedResults {
149140 assert .True (t , r .AutoFixed )
150141 assert .Equal (t , "empty-description-fixable" , r .RuleId )
151142 }
152143
153- // Verify unfixed results are only from non-fixable rule
154144 for _ , r := range result .Results {
155145 assert .False (t , r .AutoFixed )
156146 assert .Equal (t , "empty-summary-not-fixable" , r .RuleId )
0 commit comments