docker_tester

Crates.iodocker_tester
lib.rsdocker_tester
version0.1.4
sourcesrc
created_at2022-11-24 15:28:35.867411
updated_at2022-11-28 14:50:52.004481
descriptionThis library provides simple functions for starting and stopping containers using Docker.
homepage
repositoryhttps://github.com/startdusk/docker-tester
max_upload_size
id722274
size15,222
(startdusk)

documentation

https://docs.rs/docker_tester

README

docker-tester

This library provides simple functions for starting and stopping containers using Docker.

Getting started

You must have Docker installed and started

use docker_tester::start_container;

fn main() {
    let image = "postgres:latest"
    let port = "5432"
    let args = &[
        "-e",
        "POSTGRES_USER=postgres",
        "-e",
        "POSTGRES_PASSWORD=password"
    ];
    let container = start_container(image, port, args)
        .expect("Failed to start Postgres contaienr");

    assert!(container.id);
    assert!(container.host);
    assert!(container.port);
}

db-tester

use docker_tester::TestPostgres;

#[tokio::test]
async fn it_works() {
    let test_postgres = TestPostgres::new("./migrations").await.unwrap();
    let pool = test_postgres.get_pool().await;

    // do something with the pool

    // when test_postgres gets dropped, the database will be dropped on Docker
}

License

This project is distributed under the terms of MIT.

See LICENSE for details.

Copyright 2022 startdusk

Commit count: 9

cargo fmt