dockertest-rs
Run docker containers in your Rust integration tests.
This crate provides the following features for your docker testing needs:
- Ensure docker containers are invoked and running according to
WaitForstrategy. - Customize your own or use one of the batteries included.
- Interact with the
RunningContainerin the test body through itsipaddress. - Teardown each started container after test is terminated - both successfully and on test failure.
Example
The canonical example and motivation for this crate can be expressed with the following use-case example - host a database used by your test in a container, which is fresh between each test.
use PgConnection;
use *;
use ;
use ;
use Rc;
// Define our test
let source = DockerHub;
let mut test = new.with_default_source;
// Define our Composition - the Image we will start and end up as our RunningContainer
let postgres = with_repository.with_wait_for;
test.add_composition;
// Run the test body
test.run;
Development
This library is in its initial inception. Breaking changes are to be expected.
Testing
Testing this library requires the following:
- docker daemon available on localhost.
- Capable of compiling
dieselwith the postgres feature.
Run the tests with the following command:
cargo test -- --test-threads=1
Caveats that may fail tests:
- Exited
hello-worldcontainers on the system. This will currently make removing old images fail and many tests will fail.