File tree Expand file tree Collapse file tree 11 files changed +190
-0
lines changed
Expand file tree Collapse file tree 11 files changed +190
-0
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,39 @@ fn test_clean_branches_dry_run_outputs_expected() {
1414 . stdout ( contains ( "(dry run) Would delete: feature/cleanup" ) ) ;
1515}
1616
17+ #[ test]
18+ fn test_clean_branches_run_function_dry_run ( ) {
19+ let repo = repo_with_merged_branch ( "feature/test" , "master" ) ;
20+
21+ // Change to repo directory and run the function directly
22+ std:: env:: set_current_dir ( repo. path ( ) ) . unwrap ( ) ;
23+
24+ // Test that the function doesn't panic and git commands work
25+ git_x:: clean_branches:: run ( true ) ;
26+ }
27+
28+ #[ test]
29+ fn test_clean_branches_run_function_actual_delete ( ) {
30+ let repo = repo_with_merged_branch ( "feature/delete-me" , "master" ) ;
31+
32+ // Change to repo directory and run the function directly
33+ std:: env:: set_current_dir ( repo. path ( ) ) . unwrap ( ) ;
34+
35+ // Test that the function doesn't panic and actually deletes branches
36+ git_x:: clean_branches:: run ( false ) ;
37+ }
38+
39+ #[ test]
40+ fn test_clean_branches_run_function_no_branches ( ) {
41+ let repo = common:: basic_repo ( ) ;
42+
43+ // Change to repo directory - this repo has no merged branches to delete
44+ std:: env:: set_current_dir ( repo. path ( ) ) . unwrap ( ) ;
45+
46+ // Test the no branches case
47+ git_x:: clean_branches:: run ( true ) ;
48+ }
49+
1750#[ test]
1851fn test_clean_branches_actually_deletes_branch ( ) {
1952 let repo = repo_with_merged_branch ( "feature/cleanup" , "master" ) ;
Original file line number Diff line number Diff line change 1+ mod common;
2+
13use git_x:: color_graph:: * ;
24use std:: process:: { ExitStatus , Output } ;
35
@@ -54,3 +56,30 @@ fn test_convert_output_to_string() {
5456 "git log output"
5557 ) ;
5658}
59+
60+ #[ test]
61+ fn test_color_graph_run_function ( ) {
62+ let repo = common:: basic_repo ( ) ;
63+
64+ // Change to repo directory and run the function directly
65+ std:: env:: set_current_dir ( repo. path ( ) ) . unwrap ( ) ;
66+
67+ // Test that the function doesn't panic and git commands work
68+ git_x:: color_graph:: run ( ) ;
69+ }
70+
71+ #[ test]
72+ fn test_print_git_output ( ) {
73+ let test_output = b"* commit1 message\n * commit2 message" ;
74+
75+ // Test that print_git_output doesn't panic
76+ git_x:: color_graph:: print_git_output ( test_output) ;
77+ }
78+
79+ #[ test]
80+ fn test_print_git_error ( ) {
81+ let test_error = b"not a git repository" ;
82+
83+ // Test that print_git_error doesn't panic
84+ git_x:: color_graph:: print_git_error ( test_error) ;
85+ }
Original file line number Diff line number Diff line change @@ -48,3 +48,14 @@ fn test_format_git_error() {
4848 "❌ git log failed:\n permission denied"
4949 ) ;
5050}
51+
52+ #[ test]
53+ fn test_graph_run_function ( ) {
54+ let repo = common:: basic_repo ( ) ;
55+
56+ // Change to repo directory and run the function directly
57+ std:: env:: set_current_dir ( repo. path ( ) ) . unwrap ( ) ;
58+
59+ // Test that the function doesn't panic and git commands work
60+ git_x:: graph:: run ( ) ;
61+ }
Original file line number Diff line number Diff line change @@ -107,3 +107,25 @@ fn test_is_git_repo_returns_false_for_non_git_dir() {
107107 let temp_dir = tempfile:: tempdir ( ) . unwrap ( ) ;
108108 assert ! ( !is_git_repo( temp_dir. path( ) ) ) ;
109109}
110+
111+ #[ test]
112+ fn test_health_run_function_in_git_repo ( ) {
113+ let repo = common:: basic_repo ( ) ;
114+
115+ // Change to repo directory and run the function directly
116+ std:: env:: set_current_dir ( repo. path ( ) ) . unwrap ( ) ;
117+
118+ // Test that the function doesn't panic and executes all health checks
119+ git_x:: health:: run ( ) ;
120+ }
121+
122+ #[ test]
123+ fn test_health_run_function_outside_git_repo ( ) {
124+ let temp_dir = tempfile:: tempdir ( ) . unwrap ( ) ;
125+
126+ // Change to non-git directory
127+ std:: env:: set_current_dir ( temp_dir. path ( ) ) . unwrap ( ) ;
128+
129+ // Test that the function handles non-git directory gracefully
130+ git_x:: health:: run ( ) ;
131+ }
Original file line number Diff line number Diff line change @@ -82,3 +82,15 @@ fn test_format_tracking_branch() {
8282 "Tracking: upstream/develop"
8383 ) ;
8484}
85+
86+ #[ test]
87+ fn test_info_run_function ( ) {
88+ let ( repo, _remote) = repo_with_remote_ahead ( "main" ) ;
89+
90+ // Change to repo directory and run the function directly
91+ std:: env:: set_current_dir ( repo. path ( ) ) . unwrap ( ) ;
92+
93+ // Test that the function doesn't panic and git commands work
94+ // This repo has a remote upstream so it should work
95+ git_x:: info:: run ( ) ;
96+ }
Original file line number Diff line number Diff line change @@ -116,3 +116,6 @@ fn test_format_no_branches_to_prune_message() {
116116 "✅ No merged branches to prune."
117117 ) ;
118118}
119+
120+ // Note: prune_branches::run() calls exit() on errors, making it difficult to test directly
121+ // The CLI integration tests cover this functionality instead
Original file line number Diff line number Diff line change @@ -138,3 +138,6 @@ fn test_format_rename_success_message() {
138138 "Branch renamed successfully."
139139 ) ;
140140}
141+
142+ // Note: rename_branch::run() interacts with remotes, making it difficult to test directly
143+ // The CLI integration tests cover this functionality instead
Original file line number Diff line number Diff line change @@ -38,3 +38,25 @@ fn test_is_log_empty() {
3838 assert ! ( !is_log_empty( "some log output" ) ) ;
3939 assert ! ( !is_log_empty( "commit abc123" ) ) ;
4040}
41+
42+ #[ test]
43+ fn test_since_run_function ( ) {
44+ let repo = repo_with_commits ( 3 ) ;
45+
46+ // Change to repo directory and run the function directly
47+ std:: env:: set_current_dir ( repo. path ( ) ) . unwrap ( ) ;
48+
49+ // Test that the function doesn't panic and git commands work
50+ git_x:: since:: run ( "HEAD~1" . to_string ( ) ) ;
51+ }
52+
53+ #[ test]
54+ fn test_since_run_function_no_commits ( ) {
55+ let repo = common:: basic_repo ( ) ;
56+
57+ // Change to repo directory and run the function directly
58+ std:: env:: set_current_dir ( repo. path ( ) ) . unwrap ( ) ;
59+
60+ // Test with a reference that should show no commits
61+ git_x:: since:: run ( "HEAD" . to_string ( ) ) ;
62+ }
Original file line number Diff line number Diff line change @@ -123,3 +123,25 @@ fn test_parse_git_log_output() {
123123 let result = parse_git_log_output ( output) ;
124124 assert_eq ! ( result. len( ) , 2 ) ;
125125}
126+
127+ #[ test]
128+ fn test_summary_run_function ( ) {
129+ let repo = common:: repo_with_conventional_commits ( ) ;
130+
131+ // Change to repo directory and run the function directly
132+ std:: env:: set_current_dir ( repo. path ( ) ) . unwrap ( ) ;
133+
134+ // Test that the function doesn't panic and git commands work
135+ git_x:: summary:: run ( "1 day ago" . to_string ( ) ) ;
136+ }
137+
138+ #[ test]
139+ fn test_summary_run_function_no_commits ( ) {
140+ let repo = common:: basic_repo ( ) ;
141+
142+ // Change to repo directory and run the function directly
143+ std:: env:: set_current_dir ( repo. path ( ) ) . unwrap ( ) ;
144+
145+ // Test with a time range that should show no commits
146+ git_x:: summary:: run ( "1 minute ago" . to_string ( ) ) ;
147+ }
Original file line number Diff line number Diff line change @@ -50,3 +50,14 @@ fn test_format_success_message() {
5050fn test_format_error_message ( ) {
5151 assert_eq ! ( format_error_message( ) , "❌ Failed to undo last commit." ) ;
5252}
53+
54+ #[ test]
55+ fn test_undo_run_function ( ) {
56+ let repo = repo_with_commits ( 3 ) ;
57+
58+ // Change to repo directory and run the function directly
59+ std:: env:: set_current_dir ( repo. path ( ) ) . unwrap ( ) ;
60+
61+ // Test that the function doesn't panic and git commands work
62+ git_x:: undo:: run ( ) ;
63+ }
You can’t perform that action at this time.
0 commit comments