1- #[ cfg( test) ]
2- mod tests {
3- use super :: * ;
4- use crate :: cli_definitions:: { Cli , StackPreset } ;
5- use clap:: Parser ;
6- use std:: path:: PathBuf ;
1+ use crate :: cli_definitions:: { Cli , StackPreset } ;
2+ use clap:: Parser ;
3+ use std:: path:: PathBuf ;
74
8- #[ test]
9- fn test_cli_help_generation ( ) {
10- use clap:: CommandFactory ;
11- let mut cli = Cli :: command ( ) ;
12- let help_output = cli. render_help ( ) ;
5+ #[ cfg( test) ]
6+ #[ test]
7+ fn test_cli_help_generation ( ) {
8+ use clap:: CommandFactory ;
9+ let mut cli = Cli :: command ( ) ;
10+ let help_output = cli. render_help ( ) ;
1311
14- // Verify the CLI help contains our new commands
15- assert ! ( help_output. to_string( ) . contains( "production-check" ) ) ;
16- assert ! ( help_output. to_string( ) . contains( "pre-commit" ) ) ;
17- assert ! ( help_output. to_string( ) . contains( "ci-gate" ) ) ;
18- assert ! ( help_output. to_string( ) . contains( "lang" ) ) ;
19- assert ! ( help_output. to_string( ) . contains( "stack" ) ) ;
20- assert ! ( help_output. to_string( ) . contains( "watch" ) ) ;
21- }
12+ // Verify the CLI help contains our new commands
13+ assert ! ( help_output. to_string( ) . contains( "production-check" ) ) ;
14+ assert ! ( help_output. to_string( ) . contains( "pre-commit" ) ) ;
15+ assert ! ( help_output. to_string( ) . contains( "ci-gate" ) ) ;
16+ assert ! ( help_output. to_string( ) . contains( "lang" ) ) ;
17+ assert ! ( help_output. to_string( ) . contains( "stack" ) ) ;
18+ assert ! ( help_output. to_string( ) . contains( "watch" ) ) ;
19+ }
2220
23- #[ test]
24- fn test_cli_description ( ) {
25- use clap:: CommandFactory ;
26- let cli = Cli :: command ( ) ;
27- let about = cli. get_about ( ) . unwrap ( ) . to_string ( ) ;
21+ #[ cfg( test) ]
22+ #[ test]
23+ fn test_cli_description ( ) {
24+ use clap:: CommandFactory ;
25+ let cli = Cli :: command ( ) ;
26+ let about = cli. get_about ( ) . unwrap ( ) . to_string ( ) ;
2827
29- // Verify the CLI description mentions key features
30- assert ! ( about. contains( "Multi-language" ) ) ;
31- assert ! ( about. contains( "production readiness" ) ) ;
32- assert ! ( about. contains( "code quality" ) ) ;
33- // The about text is: "Multi-language code analysis tool for production readiness and code quality"
34- }
28+ // Verify the CLI description mentions key features
29+ assert ! ( about. contains( "Multi-language" ) ) ;
30+ assert ! ( about. contains( "production readiness" ) ) ;
31+ assert ! ( about. contains( "code quality" ) ) ;
32+ // The about text is: "Multi-language code analysis tool for production readiness and code quality"
33+ }
3534
36- #[ test]
37- fn test_stack_preset_variants ( ) {
38- // Test that all stack presets are properly defined
39- let web_preset = StackPreset :: Web {
40- path : PathBuf :: from ( "." ) ,
41- production : false ,
42- } ;
43- let backend_preset = StackPreset :: Backend {
44- path : PathBuf :: from ( "." ) ,
45- production : false ,
46- } ;
47- let fullstack_preset = StackPreset :: Fullstack {
48- path : PathBuf :: from ( "." ) ,
49- production : false ,
50- } ;
51- let mobile_preset = StackPreset :: Mobile {
52- path : PathBuf :: from ( "." ) ,
53- production : false ,
54- } ;
55- let systems_preset = StackPreset :: Systems {
56- path : PathBuf :: from ( "." ) ,
57- production : false ,
58- } ;
35+ #[ cfg( test) ]
36+ #[ test]
37+ fn test_stack_preset_variants ( ) {
38+ // Test that all stack presets are properly defined
39+ let web_preset = StackPreset :: Web {
40+ path : PathBuf :: from ( "." ) ,
41+ production : false ,
42+ } ;
43+ let backend_preset = StackPreset :: Backend {
44+ path : PathBuf :: from ( "." ) ,
45+ production : false ,
46+ } ;
47+ let fullstack_preset = StackPreset :: Fullstack {
48+ path : PathBuf :: from ( "." ) ,
49+ production : false ,
50+ } ;
51+ let mobile_preset = StackPreset :: Mobile {
52+ path : PathBuf :: from ( "." ) ,
53+ production : false ,
54+ } ;
55+ let systems_preset = StackPreset :: Systems {
56+ path : PathBuf :: from ( "." ) ,
57+ production : false ,
58+ } ;
5959
60- // Basic validation that variants exist
61- match web_preset {
62- StackPreset :: Web { .. } => ( ) ,
63- _ => panic ! ( "Web preset should match" ) ,
64- }
65- match backend_preset {
66- StackPreset :: Backend { .. } => ( ) ,
67- _ => panic ! ( "Backend preset should match" ) ,
68- }
69- match fullstack_preset {
70- StackPreset :: Fullstack { .. } => ( ) ,
71- _ => panic ! ( "Fullstack preset should match" ) ,
72- }
73- match mobile_preset {
74- StackPreset :: Mobile { .. } => ( ) ,
75- _ => panic ! ( "Mobile preset should match" ) ,
76- }
77- match systems_preset {
78- StackPreset :: Systems { .. } => ( ) ,
79- _ => panic ! ( "Systems preset should match" ) ,
80- }
60+ // Basic validation that variants exist
61+ match web_preset {
62+ StackPreset :: Web { .. } => ( ) ,
63+ _ => panic ! ( "Web preset should match" ) ,
8164 }
82-
83- #[ test]
84- fn test_cli_parse_invalid_subcommand ( ) {
85- let args = vec ! [ "code-guardian" , "invalid" ] ;
86- let result = Cli :: try_parse_from ( args) ;
87- assert ! ( result. is_err( ) ) ;
65+ match backend_preset {
66+ StackPreset :: Backend { .. } => ( ) ,
67+ _ => panic ! ( "Backend preset should match" ) ,
8868 }
89-
90- #[ test]
91- fn test_cli_parse_scan_missing_path ( ) {
92- let args = vec ! [ "code-guardian" , "scan" ] ;
93- let result = Cli :: try_parse_from ( args) ;
94- assert ! ( result. is_err( ) ) ;
69+ match fullstack_preset {
70+ StackPreset :: Fullstack { .. } => ( ) ,
71+ _ => panic ! ( "Fullstack preset should match" ) ,
9572 }
96-
97- #[ test]
98- fn test_cli_parse_report_missing_id ( ) {
99- let args = vec ! [ "code-guardian" , "report" ] ;
100- let result = Cli :: try_parse_from ( args) ;
101- assert ! ( result. is_err( ) ) ;
73+ match mobile_preset {
74+ StackPreset :: Mobile { .. } => ( ) ,
75+ _ => panic ! ( "Mobile preset should match" ) ,
10276 }
103-
104- #[ test]
105- fn test_handle_history_invalid_db ( ) {
106- use crate :: command_handlers:: handle_history;
107- let invalid_db = PathBuf :: from ( "/invalid/path/db.db" ) ;
108- let result = handle_history ( Some ( invalid_db) ) ;
109- assert ! ( result. is_err( ) ) ;
77+ match systems_preset {
78+ StackPreset :: Systems { .. } => ( ) ,
79+ _ => panic ! ( "Systems preset should match" ) ,
11080 }
81+ }
11182
112- #[ test]
113- fn test_handle_benchmark_invalid_path ( ) {
114- use crate :: command_handlers:: handle_benchmark;
115- let invalid_path = PathBuf :: from ( "/invalid/path" ) ;
116- let result = handle_benchmark ( Some ( invalid_path) , false ) ;
117- assert ! ( result. is_err( ) ) ;
118- }
83+ #[ cfg( test) ]
84+ #[ test]
85+ fn test_cli_parse_invalid_subcommand ( ) {
86+ let args = vec ! [ "code-guardian" , "invalid" ] ;
87+ let result = Cli :: try_parse_from ( args) ;
88+ assert ! ( result. is_err( ) ) ;
11989}
90+
91+ #[ cfg( test) ]
92+ #[ test]
93+ fn test_cli_parse_scan_missing_path ( ) {
94+ let args = vec ! [ "code-guardian" , "scan" ] ;
95+ let result = Cli :: try_parse_from ( args) ;
96+ assert ! ( result. is_err( ) ) ;
97+ }
98+
99+ #[ cfg( test) ]
100+ #[ test]
101+ fn test_cli_parse_report_missing_id ( ) {
102+ let args = vec ! [ "code-guardian" , "report" ] ;
103+ let result = Cli :: try_parse_from ( args) ;
104+ assert ! ( result. is_err( ) ) ;
105+ }
106+
107+ #[ cfg( test) ]
108+ #[ test]
109+ fn test_handle_history_invalid_db ( ) {
110+ use crate :: command_handlers:: handle_history;
111+ let invalid_db = PathBuf :: from ( "/invalid/path/db.db" ) ;
112+ let result = handle_history ( Some ( invalid_db) ) ;
113+ assert ! ( result. is_err( ) ) ;
114+ }
115+
116+ #[ cfg( test) ]
117+ #[ test]
118+ fn test_handle_benchmark_invalid_path ( ) {
119+ use crate :: command_handlers:: handle_benchmark;
120+ let invalid_path = PathBuf :: from ( "/invalid/path" ) ;
121+ let result = handle_benchmark ( Some ( invalid_path) , false ) ;
122+ assert ! ( result. is_err( ) ) ;
123+ }
0 commit comments