rustainers 0.15.1

A simple, opinionated way to run containers for tests.
Documentation
//! Custom container tests.

use assert2::let_assert;
use rstest::rstest;

use rustainers::runner::{RunOption, Runner};
use rustainers::{
    ContainerStatus, ImageName, RunnableContainer, RunnableContainerBuilder, ToRunnableContainer,
};
use tracing::error;

mod common;
pub use self::common::*;

#[derive(Debug, Clone, Copy)]
struct HelloWorld;

impl ToRunnableContainer for HelloWorld {
    fn to_runnable(&self, builder: RunnableContainerBuilder) -> RunnableContainer {
        builder
            .with_image(ImageName::new("hello-world"))
            .with_wait_strategy(ContainerStatus::Exited)
            .build()
    }
}

#[rstest]
#[tokio::test]
async fn should_run_hello_world(runner: &Runner) {
    _ = tracing_subscriber::fmt::try_init();

    let result = runner
        .start_with_options(HelloWorld, RunOption::default())
        .await;
    if let Err(err) = &result {
        error!("{err}");
    }
    let_assert!(Ok(_) = result);
}