@@ -81,52 +81,63 @@ pub fn register() {
8181#[ cfg( all( test, feature = "slow-tests" ) ) ]
8282mod tests {
8383 use super :: register;
84- use homeboy_code_audit:: { audit_path_with_id, report:: compute_fixability} ;
84+ use homeboy_code_audit:: {
85+ report:: compute_fixability, AuditFinding , AuditSummary , CodeAuditResult , Finding , Severity ,
86+ } ;
8587 use std:: fs;
8688
8789 #[ test]
8890 fn computes_fixability_through_the_registered_audit_provider ( ) {
8991 register ( ) ;
9092
91- homeboy_core:: test_support:: with_isolated_audit_home ( |home| {
92- homeboy_core:: test_support:: write_source_extension (
93- home. path ( ) ,
94- "source-fixture" ,
95- "fixture" ,
96- ) ;
97- let dir = tempfile:: tempdir ( ) . expect ( "temp dir" ) ;
98- let root = dir. path ( ) ;
99- fs:: create_dir_all ( root. join ( "commands" ) ) . expect ( "create commands directory" ) ;
100- fs:: write (
101- root. join ( "commands/good_one.fixture" ) ,
102- "pub fn run() {}\n pub fn helper() {}\n " ,
103- )
104- . expect ( "write first convention fixture" ) ;
105- fs:: write (
106- root. join ( "commands/good_two.fixture" ) ,
107- "pub fn run() {}\n pub fn helper() {}\n " ,
93+ let dir = tempfile:: tempdir ( ) . expect ( "temp dir" ) ;
94+ let root = dir. path ( ) ;
95+ fs:: write (
96+ root. join ( "todo.rs" ) ,
97+ "// TODO: add helper\n pub fn run() {}\n " ,
98+ )
99+ . expect ( "write TODO fixture" ) ;
100+ let result = CodeAuditResult {
101+ component_id : "fixability-test" . to_string ( ) ,
102+ source_path : root. to_string_lossy ( ) . to_string ( ) ,
103+ summary : AuditSummary {
104+ files_scanned : 1 ,
105+ conventions_detected : 0 ,
106+ outliers_found : 1 ,
107+ alignment_score : None ,
108+ files_skipped : 0 ,
109+ warnings : vec ! [ ] ,
110+ } ,
111+ conventions : vec ! [ ] ,
112+ directory_conventions : vec ! [ ] ,
113+ findings : vec ! [ Finding {
114+ convention: "comment_hygiene" . to_string( ) ,
115+ severity: Severity :: Info ,
116+ file: "todo.rs" . to_string( ) ,
117+ description: "Comment marker 'TODO' found on line 1: TODO: add helper" . to_string( ) ,
118+ suggestion: "Resolve the TODO" . to_string( ) ,
119+ kind: AuditFinding :: TodoMarker ,
120+ line: None ,
121+ } ] ,
122+ duplicate_groups : vec ! [ ] ,
123+ } ;
124+ let fixability = compute_fixability ( & result) . unwrap_or_else ( || {
125+ panic ! (
126+ "registered fixability provider should produce a plan; audit findings: {:#?}" ,
127+ result. findings
108128 )
109- . expect ( "write second convention fixture" ) ;
110- fs:: write ( root. join ( "commands/bad.fixture" ) , "pub fn run() {}\n " )
111- . expect ( "write convention outlier fixture" ) ;
112-
113- let result = audit_path_with_id ( "fixability-test" , & root. to_string_lossy ( ) )
114- . expect ( "audit should run" ) ;
115- let fixability = compute_fixability ( & result) ;
116-
117- // The compact fixture may not yield enough conventions for a plan,
118- // but any plan must retain the provider's complete public summary.
119- if let Some ( fix) = fixability {
120- assert ! (
121- fix. fixable_count > 0 ,
122- "expected at least one fixable finding"
123- ) ;
124- assert_eq ! (
125- fix. fixable_count,
126- fix. automated_count + fix. manual_only_count
127- ) ;
128- assert ! ( !fix. by_kind. is_empty( ) , "expected per-kind breakdown" ) ;
129- }
130129 } ) ;
130+
131+ assert_eq ! ( fixability. fixable_count, 1 ) ;
132+ assert_eq ! ( fixability. automated_count, 0 ) ;
133+ assert_eq ! ( fixability. manual_only_count, 1 ) ;
134+ assert_eq ! ( fixability. by_kind. len( ) , 1 ) ;
135+ let todo_marker = fixability
136+ . by_kind
137+ . get ( "todo_marker" )
138+ . expect ( "fixability summary should include the TODO marker" ) ;
139+ assert_eq ! ( todo_marker. total, 1 ) ;
140+ assert_eq ! ( todo_marker. automated, 0 ) ;
141+ assert_eq ! ( todo_marker. manual_only, 1 ) ;
131142 }
132143}
0 commit comments