An ubuntu docker image is used as test environment for dra
executable.
Inside it's installed the dra
executable that is used for the tests.
Tests are written in rust. It's possible to interact with docker api through a custom wrapper called Docker.
-
Start docker container
dra-ubuntu
withDocker::run()
-
Execute
dra
command to be tested and wait for its result usingDocker::exec()
.You need to use devmatteini/dra-tests repository.
-
Do assertions on command result (you can find helpers methods in assertions module)
Note: when the docker container started in step 1 goes out of scope, is then stopped in background.
Example:
use crate::assertions::{assert_contains, assert_success};
use crate::docker::{images, Docker, ExecArgs};
#[test]
fn print_right_version() {
let container = Docker::run(images::UBUNTU);
let result = container.exec("dra --version", ExecArgs::Default);
let output = assert_success(result);
assert_contains("0.2.3", &output);
}