https://github.com/startdusk/docker-tester
https://github.com/startdusk/docker-tester
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/startdusk/docker-tester
- Owner: startdusk
- License: mit
- Created: 2022-11-24T14:36:27.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-11-28T14:50:03.000Z (over 3 years ago)
- Last Synced: 2025-04-28T02:03:37.214Z (about 1 year ago)
- Language: Rust
- Size: 9.77 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# docker-tester
This library provides simple functions for starting and stopping containers using Docker.
## Getting started
You must have Docker installed and started
```rust
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
```rust
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](./LICENSE) for details.
Copyright 2022 startdusk