File tree Expand file tree Collapse file tree 2 files changed +11
-10
lines changed
Expand file tree Collapse file tree 2 files changed +11
-10
lines changed Original file line number Diff line number Diff line change @@ -272,16 +272,16 @@ async fn async_copy_files_to_container() -> anyhow::Result<()> {
272272async fn async_container_is_running ( ) -> anyhow:: Result < ( ) > {
273273 let _ = pretty_env_logger:: try_init ( ) ;
274274
275- // Container that should run for 1 second
276- let container = GenericImage :: new ( "alpine " , "latest" )
277- . with_cmd ( vec ! [ "sleep" , "1" ] )
275+ // Container that should run until manually quit
276+ let container = GenericImage :: new ( "simple_web_server " , "latest" )
277+ . with_wait_for ( WaitFor :: message_on_stdout ( "server is ready" ) )
278278 . start ( )
279279 . await ?;
280280
281281 assert ! ( container. is_running( ) . await ?) ;
282282
283- // After waiting for two seconds it shouldn't be running anymore
284- tokio :: time :: sleep ( Duration :: from_secs ( 2 ) ) . await ;
283+ container . stop ( ) . await ? ;
284+
285285 assert ! ( !container. is_running( ) . await ?) ;
286286
287287 Ok ( ( ) )
Original file line number Diff line number Diff line change @@ -288,18 +288,19 @@ fn sync_copy_files_to_container() -> anyhow::Result<()> {
288288 Ok ( ( ) )
289289}
290290
291+ #[ test]
291292fn sync_container_is_running ( ) -> anyhow:: Result < ( ) > {
292293 let _ = pretty_env_logger:: try_init ( ) ;
293294
294- // Container that should run for 1 second
295- let container = GenericImage :: new ( "alpine " , "latest" )
296- . with_cmd ( vec ! [ "sleep" , "1" ] )
295+ // Container that should run until manually quit
296+ let container = GenericImage :: new ( "simple_web_server " , "latest" )
297+ . with_wait_for ( WaitFor :: message_on_stdout ( "server is ready" ) )
297298 . start ( ) ?;
298299
299300 assert ! ( container. is_running( ) ?) ;
300301
301- // After waiting for two seconds it shouldn't be running anymore
302- std :: thread :: sleep ( Duration :: from_secs ( 2 ) ) ;
302+ container . stop ( ) ? ;
303+
303304 assert ! ( !container. is_running( ) ?) ;
304305
305306 Ok ( ( ) )
You can’t perform that action at this time.
0 commit comments