with_postgres_ready/lib.rs
1//! `with_postgres_ready` makes it easy to write tests that relies on a postgres database being ready to accept connections.
2//! It does this by starting a Docker container with postgres, polling the database until it is ready, and then executing the block.
3//!
4//! # Examples
5//! To get a connection url with the default configuration:
6//! ```rust
7//! use with_postgres_ready::*;
8//!
9//! #[test_log::test]
10//! fn it_can_use_defaults() {
11//! with_postgres_ready(|url| async move {
12//! // Connect to the database using the url.
13//! });
14//! }
15//! ```
16//!
17//! To get more control, use the `Runner` builder:
18//! ```rust
19//! use with_postgres_ready::*;
20//!
21//! #[test_log::test]
22//! fn it_can_use_custom_connection_timeout() {
23//! Runner::new().connection_timeout(Duration::from_secs(5)).run(|url| async move {
24//! // Connect to the database using the url.
25//! });
26//! }
27//! ```
28
29mod helper;
30mod runner;
31
32pub use helper::with_postgres_ready;
33pub use runner::Runner;