Closed
Description
libcnb-test tears down started containers in TestContext::drop
, however, if the test panics prior to the creation of the TestContext
this teardown never occurs. This can happen when the container spawn failed (eg invalid command).
libcnb.rs/libcnb-test/src/test_context.rs
Lines 109 to 115 in e030d1c
This can be seen by running the start_container_spawn_failure
test:
$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
$ cargo test -p libcnb-test -- --ignored start_container_spawn_failure
Finished test [unoptimized + debuginfo] target(s) in 0.04s
Running unittests src/lib.rs (/Users/emorley/src/libcnb.rs/target/debug/deps/libcnb_test-52afd8d3986e3490)
running 0 tests
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 32 filtered out; finished in 0.00s
Running tests/integration_test.rs (/Users/emorley/src/libcnb.rs/target/debug/deps/integration_test-766c079bdc09c04d)
running 1 test
test start_container_spawn_failure - should panic ... ok
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 26 filtered out; finished in 1.03s
Doc-tests libcnb-test
running 0 tests
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 38 filtered out; finished in 0.01s
$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
bd1eba167270 73a710102aa6 "nonexistent-command" 2 seconds ago Created libcnbtest_vqvzlpmsjirt
4420