Skip to content

Commit

Permalink
Removed shutdown test. Refactored running testcontainers for db testing.
Browse files Browse the repository at this point in the history
  • Loading branch information
piohei committed Apr 29, 2024
1 parent a16c169 commit c1f0cf3
Show file tree
Hide file tree
Showing 22 changed files with 344 additions and 220 deletions.
17 changes: 7 additions & 10 deletions crates/postgres-docker-utils/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use testcontainers::{clients::Cli, Container, RunnableImage};
use testcontainers::clients::Cli;
use testcontainers::{Container, RunnableImage};
use testcontainers_modules::postgres::Postgres;

pub struct DockerContainer<'a> {
Expand All @@ -7,21 +8,17 @@ pub struct DockerContainer<'a> {

impl<'a> DockerContainer<'a> {
fn new(docker: &'a Cli) -> Self {
let image = RunnableImage::from(Postgres::default().with_host_auth()).with_tag("16.2-alpine");
let image =
RunnableImage::from(Postgres::default().with_host_auth()).with_tag("16.2-alpine");
let container = docker.run(image);
DockerContainer {
container,
}
DockerContainer { container }
}

pub fn address(&self) -> String {
return format!(
"127.0.0.1:{}", self.container.get_host_port_ipv4(5432),
)
format!("127.0.0.1:{}", self.container.get_host_port_ipv4(5432))
}
}


pub async fn setup<'a>(docker: &'a Cli) -> anyhow::Result<DockerContainer<'a>> {
pub async fn setup(docker: &Cli) -> anyhow::Result<DockerContainer> {
Ok(DockerContainer::new(docker))
}
Loading

0 comments on commit c1f0cf3

Please sign in to comment.