@@ -59,117 +59,3 @@ pub fn kill_container(ctx: Context, mut cli_args: cli::CmdKillArgs) -> Result<()
5959
6060 Ok ( ( ) )
6161}
62-
63- #[ cfg( test) ]
64- mod tests {
65- use crate :: engine:: Podman ;
66- use crate :: tests_prelude:: * ;
67- use assert_cmd:: prelude:: * ;
68- use rexpect:: session:: spawn_command;
69- use std:: process:: Command ;
70-
71- #[ test]
72- #[ ignore]
73- fn cmd_kill_podman ( ) -> Result < ( ) > {
74- let tempdir = tempfile:: tempdir ( ) ?;
75-
76- // create the container
77- let cmd = Command :: cargo_bin ( env ! ( "CARGO_BIN_NAME" ) ) ?
78- . args ( [ "start" , DEBIAN_IMAGE ] )
79- . current_dir ( tempdir. path ( ) )
80- . assert ( )
81- . success ( ) ;
82-
83- let container = Container {
84- engine : Box :: new ( Podman ) ,
85- container : String :: from_utf8_lossy ( & cmd. get_output ( ) . stdout )
86- . trim ( )
87- . to_string ( ) ,
88- } ;
89-
90- // it should exist now
91- Command :: cargo_bin ( env ! ( "CARGO_BIN_NAME" ) ) ?
92- . args ( [ "exists" ] )
93- . current_dir ( tempdir. path ( ) )
94- . assert ( )
95- . success ( ) ;
96-
97- // test with --yes
98- Command :: cargo_bin ( env ! ( "CARGO_BIN_NAME" ) ) ?
99- . args ( [ "kill" , "-y" , & container] )
100- . current_dir ( tempdir. path ( ) )
101- . assert ( )
102- . success ( ) ;
103-
104- Ok ( ( ) )
105- }
106-
107- #[ test]
108- #[ ignore]
109- fn cmd_kill_interactive_podman ( ) -> Result < ( ) > {
110- let tempdir = tempfile:: tempdir ( ) ?;
111-
112- let cmd = Command :: cargo_bin ( env ! ( "CARGO_BIN_NAME" ) ) ?
113- . args ( [ "start" , DEBIAN_IMAGE ] )
114- . current_dir ( tempdir. path ( ) )
115- . assert ( )
116- . success ( ) ;
117-
118- let container = Container {
119- engine : Box :: new ( Podman ) ,
120- container : String :: from_utf8_lossy ( & cmd. get_output ( ) . stdout )
121- . trim ( )
122- . to_string ( ) ,
123- } ;
124-
125- // try to kill to get the prompt
126- let mut pty = {
127- let mut c = Command :: cargo_bin ( env ! ( "CARGO_PKG_NAME" ) ) ?;
128- c. args ( [ "kill" , & container] ) ;
129-
130- spawn_command ( c, Some ( 5_000 ) )
131- } ?;
132-
133- let ( _, matched) = pty. exp_regex ( r#"\"(.+)\".*\[y/N\]"# ) ?;
134- assert ! (
135- matched. contains( & * container) ,
136- "Wrong container name in prompt?"
137- ) ;
138-
139- // send enter? so i check the default action
140- pty. send_line ( "" ) ?;
141- pty. exp_eof ( ) ?;
142-
143- // check if container is still running, as it should be
144- Command :: new ( "podman" )
145- . args ( [ "container" , "exists" , & container] )
146- . assert ( )
147- . success ( ) ;
148-
149- // run again and answer y
150- let mut pty = {
151- let mut c = Command :: cargo_bin ( env ! ( "CARGO_PKG_NAME" ) ) ?;
152- c. args ( [ "kill" , & container] ) ;
153-
154- spawn_command ( c, Some ( 5_000 ) )
155- } ?;
156-
157- let ( _, matched) = pty. exp_regex ( r#"\"(.+)\".*\[y/N\]"# ) ?;
158- assert ! (
159- matched. contains( & * container) ,
160- "Wrong container name in prompt?"
161- ) ;
162-
163- // send enter? so i check the default action
164- pty. send_line ( "y" ) ?;
165- pty. exp_eof ( ) ?;
166-
167- // check if container is still running, it should not be at this point
168- Command :: new ( "podman" )
169- . args ( [ "container" , "exists" , & container] )
170- . assert ( )
171- . failure ( ) ;
172-
173- Ok ( ( ) )
174- }
175- }
0 commit comments