File tree 2 files changed +12
-12
lines changed 2 files changed +12
-12
lines changed Original file line number Diff line number Diff line change @@ -272,17 +272,17 @@ async fn async_copy_files_to_container() -> anyhow::Result<()> {
272
272
async fn async_container_exit_code ( ) -> anyhow:: Result < ( ) > {
273
273
let _ = pretty_env_logger:: try_init ( ) ;
274
274
275
- // Container that should run for 1 second and exit with a specific doe
276
- let container = GenericImage :: new ( "alpine " , "latest" )
277
- . with_cmd ( vec ! [ "/bin/sh" , "-c" , "sleep 1 && exit 4" ] )
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" ) )
278
278
. start ( )
279
279
. await ?;
280
280
281
281
assert_eq ! ( container. exit_code( ) . await ?, None ) ;
282
282
283
- // After waiting for two seconds it shouldn't be running anymore
284
- tokio :: time :: sleep ( Duration :: from_secs ( 2 ) ) . await ;
285
- assert_eq ! ( container. exit_code( ) . await ?, Some ( 4 ) ) ;
283
+ container . stop ( ) . await ? ;
284
+
285
+ assert_eq ! ( container. exit_code( ) . await ?, Some ( 0 ) ) ;
286
286
287
287
Ok ( ( ) )
288
288
}
Original file line number Diff line number Diff line change @@ -292,16 +292,16 @@ fn sync_copy_files_to_container() -> anyhow::Result<()> {
292
292
fn sync_container_exit_code ( ) -> anyhow:: Result < ( ) > {
293
293
let _ = pretty_env_logger:: try_init ( ) ;
294
294
295
- // Container that should run for 1 second and exit with a specific doe
296
- let container = GenericImage :: new ( "alpine " , "latest" )
297
- . with_cmd ( vec ! [ "/bin/sh" , "-c" , "sleep 1 && exit 4" ] )
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" ) )
298
298
. start ( ) ?;
299
299
300
300
assert_eq ! ( container. exit_code( ) ?, None ) ;
301
301
302
- // After waiting for two seconds it shouldn't be running anymore
303
- std :: thread :: sleep ( Duration :: from_secs ( 2 ) ) ;
304
- assert_eq ! ( container. exit_code( ) ?, Some ( 4 ) ) ;
302
+ container . stop ( ) ? ;
303
+
304
+ assert_eq ! ( container. exit_code( ) ?, Some ( 0 ) ) ;
305
305
306
306
Ok ( ( ) )
307
307
}
You can’t perform that action at this time.
0 commit comments