These are rust tests that can run on your machine that do not affect your system.
Example: integration_tests.rs
When your tests affect your system, like installing a .deb release asset, you should use a sandbox environment.
An ubuntu docker image is provided as test environment with dra executable.
Tests are written in rust. It's possible to interact with docker api through a custom wrapper called Docker.
-
Start docker container
dra-ubuntuwithDocker::run() -
Execute
dracommand 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);
}