@@ -2,7 +2,7 @@ use assert_cmd::assert::OutputAssertExt;
22use assert_cmd:: cargo_bin;
33use predicates:: prelude:: * ;
44use std:: process:: Command ;
5- use wiremock:: matchers:: { method, path} ;
5+ use wiremock:: matchers:: { body_json , method, path} ;
66use wiremock:: { Mock , MockServer , ResponseTemplate } ;
77
88#[ tokio:: test]
@@ -17,7 +17,7 @@ async fn test_cli_health_command_integration() {
1717 . mount ( & mock_server)
1818 . await ;
1919
20- let mut cmd = Command :: new ( cargo_bin ! ( ) ) ;
20+ let mut cmd = Command :: new ( cargo_bin ! ( "hotfix" ) ) ;
2121 cmd. arg ( "--url" )
2222 . arg ( mock_server. uri ( ) )
2323 . arg ( "health" )
@@ -43,7 +43,7 @@ async fn test_cli_session_info_command_integration() {
4343 . mount ( & mock_server)
4444 . await ;
4545
46- let mut cmd = Command :: new ( cargo_bin ! ( ) ) ;
46+ let mut cmd = Command :: new ( cargo_bin ! ( "hotfix" ) ) ;
4747 cmd. arg ( "--url" )
4848 . arg ( mock_server. uri ( ) )
4949 . arg ( "session-info" )
@@ -67,7 +67,7 @@ async fn test_cli_reset_command_integration() {
6767 . mount ( & mock_server)
6868 . await ;
6969
70- let mut cmd = Command :: new ( cargo_bin ! ( ) ) ;
70+ let mut cmd = Command :: new ( cargo_bin ! ( "hotfix" ) ) ;
7171 cmd. arg ( "--url" )
7272 . arg ( mock_server. uri ( ) )
7373 . arg ( "reset" )
@@ -82,11 +82,12 @@ async fn test_cli_shutdown_command_integration() {
8282
8383 Mock :: given ( method ( "POST" ) )
8484 . and ( path ( "/api/shutdown" ) )
85+ . and ( body_json ( serde_json:: json!( { "reconnect" : true } ) ) )
8586 . respond_with ( ResponseTemplate :: new ( 200 ) . set_body_json ( serde_json:: json!( { } ) ) )
8687 . mount ( & mock_server)
8788 . await ;
8889
89- let mut cmd = Command :: new ( cargo_bin ! ( ) ) ;
90+ let mut cmd = Command :: new ( cargo_bin ! ( "hotfix" ) ) ;
9091 cmd. arg ( "--url" )
9192 . arg ( mock_server. uri ( ) )
9293 . arg ( "shutdown" )
@@ -95,9 +96,31 @@ async fn test_cli_shutdown_command_integration() {
9596 . stdout ( predicate:: str:: contains ( "Shutdown requested successfully" ) ) ;
9697}
9798
99+ #[ tokio:: test]
100+ async fn test_cli_shutdown_command_with_reconnect_false ( ) {
101+ let mock_server = MockServer :: start ( ) . await ;
102+
103+ Mock :: given ( method ( "POST" ) )
104+ . and ( path ( "/api/shutdown" ) )
105+ . and ( body_json ( serde_json:: json!( { "reconnect" : false } ) ) )
106+ . respond_with ( ResponseTemplate :: new ( 200 ) . set_body_json ( serde_json:: json!( { } ) ) )
107+ . mount ( & mock_server)
108+ . await ;
109+
110+ let mut cmd = Command :: new ( cargo_bin ! ( "hotfix" ) ) ;
111+ cmd. arg ( "--url" )
112+ . arg ( mock_server. uri ( ) )
113+ . arg ( "shutdown" )
114+ . arg ( "--reconnect" )
115+ . arg ( "false" )
116+ . assert ( )
117+ . success ( )
118+ . stdout ( predicate:: str:: contains ( "Shutdown requested successfully" ) ) ;
119+ }
120+
98121#[ tokio:: test]
99122async fn test_cli_help_command ( ) {
100- let mut cmd = Command :: new ( cargo_bin ! ( ) ) ;
123+ let mut cmd = Command :: new ( cargo_bin ! ( "hotfix" ) ) ;
101124 cmd. arg ( "--help" )
102125 . assert ( )
103126 . success ( )
@@ -120,7 +143,7 @@ async fn test_cli_error_handling() {
120143 . mount ( & mock_server)
121144 . await ;
122145
123- let mut cmd = Command :: new ( cargo_bin ! ( ) ) ;
146+ let mut cmd = Command :: new ( cargo_bin ! ( "hotfix" ) ) ;
124147 cmd. arg ( "--url" )
125148 . arg ( mock_server. uri ( ) )
126149 . arg ( "reset" )
@@ -141,7 +164,7 @@ async fn test_cli_with_env_var() {
141164 . mount ( & mock_server)
142165 . await ;
143166
144- let mut cmd = Command :: new ( cargo_bin ! ( ) ) ;
167+ let mut cmd = Command :: new ( cargo_bin ! ( "hotfix" ) ) ;
145168 cmd. env ( "HOTFIX_WEB_URL" , mock_server. uri ( ) )
146169 . arg ( "health" )
147170 . assert ( )
0 commit comments