@@ -71,6 +71,13 @@ fn test_parse_commit_line() {
7171 let result = parse_commit_line ( line) ;
7272 assert ! ( result. is_some( ) ) ;
7373
74+ if let Some ( ( date, formatted) ) = result {
75+ assert_eq ! ( date. to_string( ) , "2023-07-15" ) ;
76+ assert ! ( formatted. contains( "fix: bug in parser" ) ) ;
77+ assert ! ( formatted. contains( "John Doe" ) ) ;
78+ assert ! ( formatted. contains( "2 hours ago" ) ) ;
79+ }
80+
7481 let invalid_line = "abc123|incomplete" ;
7582 assert ! ( parse_commit_line( invalid_line) . is_none( ) ) ;
7683}
@@ -145,3 +152,25 @@ fn test_summary_run_function_no_commits() {
145152 // Test with a time range that should show no commits
146153 git_x:: summary:: run ( "1 minute ago" . to_string ( ) ) ;
147154}
155+
156+ #[ test]
157+ fn test_summary_run_function_git_error ( ) {
158+ let temp_dir = tempfile:: tempdir ( ) . unwrap ( ) ;
159+
160+ // Change to non-git directory to trigger error path
161+ std:: env:: set_current_dir ( temp_dir. path ( ) ) . unwrap ( ) ;
162+
163+ // Test that the function handles git command failure gracefully
164+ git_x:: summary:: run ( "1 day ago" . to_string ( ) ) ;
165+ }
166+
167+ #[ test]
168+ fn test_summary_run_function_empty_output ( ) {
169+ let repo = common:: basic_repo ( ) ;
170+
171+ // Change to repo directory and run the function directly
172+ std:: env:: set_current_dir ( repo. path ( ) ) . unwrap ( ) ;
173+
174+ // Test with a time range that should produce empty output (future date)
175+ git_x:: summary:: run ( "1 day from now" . to_string ( ) ) ;
176+ }
0 commit comments