ephemeral-postgres
Ephemeral PostgreSQL instances for Rust integration tests, backed by testcontainers (Docker).
Each test starts its own PostgreSQL container and carves out isolated databases from it, so tests never share state. Containers are removed automatically when the cluster is dropped.
Requirements
A running Docker daemon. Docker is needed only at test runtime to start containers — it is not required to build the crate or its documentation.
Install
[]
= "0.1"
Usage
use Cluster;
use Row;
async
Cluster::start()starts one PostgreSQL container.create_database()/create_database_with_id(uuid)create freshly-isolated databases that share the container.database.pool()returns ansqlx::PgPoolconnected to that database.- Dropping the last
Arc<Cluster>stops and removes the container.
Configuration
use Duration;
use Cluster;
use ClusterParams;
let cluster = start_with_params
.await?;
ClusterParams::default() pins a specific postgres image digest and waits up to 30 seconds for
the server to accept connections.
License
Apache-2.0.