Skip to content

Latest commit

 

History

History
38 lines (24 loc) · 1.18 KB

README.md

File metadata and controls

38 lines (24 loc) · 1.18 KB

Integration tests

Environment

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.

Test architecture

Tests are written in rust. It's possible to interact with docker api through a custom wrapper called Docker.

How to write a test

  1. Start docker container dra-ubuntu with Docker::run()

  2. Execute dra command to be tested and wait for its result using Docker::exec().

    You need to use devmatteini/dra-tests repository.

  3. 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);
}