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 22, 2024
1 parent 462c724 commit 79ed1bb
Show file tree
Hide file tree
Showing 17 changed files with 316 additions and 201 deletions.
15 changes: 6 additions & 9 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),
)
return format!("127.0.0.1:{}", self.container.get_host_port_ipv4(5432),);

Check warning on line 18 in crates/postgres-docker-utils/src/lib.rs

View workflow job for this annotation

GitHub Actions / Lint

unneeded `return` statement
}
}


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

Check warning on line 22 in crates/postgres-docker-utils/src/lib.rs

View workflow job for this annotation

GitHub Actions / Lint

the following explicit lifetimes could be elided: 'a
Ok(DockerContainer::new(docker))
}
Loading

0 comments on commit 79ed1bb

Please sign in to comment.