use testcontainers::images::redis::Redis;
use testcontainers::images::postgres::Postgres;
use testcontainers::Container;
pub fn setup_redis_container() -> Container<'static, Redis> {
testcontainers::run("redis:7-alpine")
.expect("Failed to start Redis container")
}
pub fn setup_postgres_container() -> Container<'static, Postgres> {
testcontainers::run("postgres:15-alpine")
.with_env_var("POSTGRES_USER", "test")
.with_env_var("POSTGRES_PASSWORD", "test")
.with_env_var("POSTGRES_DB", "test")
.expect("Failed to start PostgreSQL container")
}
pub fn get_redis_url(container: &Container<'static, Redis>) -> String {
let host_port = container.get_host_port_ipv4(6379);
format!("redis://127.0.0.1:{}", host_port)
}
pub fn get_postgres_url(container: &Container<'static, Postgres>) -> String {
let host_port = container.get_host_port_ipv4(5432);
format!(
"postgres://test:test@127.0.0.1:{}/test",
host_port
)
}