Skip to content

Commit

Permalink
fixes false positive for container ready
Browse files Browse the repository at this point in the history
  • Loading branch information
0o-de-lally committed Oct 28, 2024
1 parent e517803 commit f067943
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 35 deletions.
30 changes: 0 additions & 30 deletions warehouse/tests/sqlx_meta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,35 +53,6 @@ async fn sql_insert_test(pool: Pool<Sqlite>) -> anyhow::Result<()> {
Ok(())
}

// #[sqlx::test]
// async fn test_migrate_from_file(pool: Pool<Sqlite>) -> anyhow::Result<()> {
// // The directory must be relative to the project root (the directory containing Cargo.toml), unlike include_str!() which uses compiler internals to get the path of the file where it was invoked.
// sqlx::migrate!("tests/mock_migrations").run(&pool).await?;

// let mut conn = pool.acquire().await?;

// let id = sqlx::query(
// r#"
// INSERT INTO foo (contact_id, first_name)
// VALUES
// (1, "hello");
// "#,
// )
// .execute(&mut *conn)
// .await?
// .last_insert_rowid();

// assert!(id == 1);

// let a = sqlx::query("SELECT * FROM foo")
// .fetch_all(&mut *conn)
// .await?;

// let q = a.first().unwrap().get_unchecked::<u64, _>(0);
// assert!(q == 1);

// Ok(())
// }

#[tokio::test]

Expand Down Expand Up @@ -110,6 +81,5 @@ async fn test_migrate_from_file_pg() -> anyhow::Result<()> {

let q = a.first().unwrap().get_unchecked::<i64, _>(0);
assert!(q == 1);

Ok(())
}
7 changes: 2 additions & 5 deletions warehouse/tests/support/pg_testcontainer.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use once_cell::sync::Lazy;
use sqlx::PgPool;
use std::{thread, time::Duration};
use testcontainers::{clients::Cli, core::WaitFor, Container, GenericImage, RunnableImage};

// need to wrap the docker cli in a once_cell so that the borrow does not cause issues when container is passed along
Expand Down Expand Up @@ -32,16 +31,14 @@ pub fn start_container<'a>() -> Container<'a, GenericImage> {
.with_env_var("POSTGRES_USER".to_owned(), "postgres".to_owned())
.with_env_var("POSTGRES_PASSWORD".to_owned(), "postgres".to_owned())
.with_wait_for(WaitFor::message_on_stdout(
"database system is ready to accept connections",
// "database system is ready to accept connections",
"PostgreSQL init process complete; ready for start up."
));

let image = RunnableImage::from(container);
// need to wrap the docker cli in a once_cell so that the borrow does not cause issues when container is passed along
let container = CLI.run(image);
container.start();
// TODO: not sure why we need a bit of a wait since we have the WaitFor above
// will otherwise get: "unexpected response from SSLRequest: 0x00 (sqlx_postgres::connection::tls:97)"
thread::sleep(Duration::from_millis(500));

container
}
Expand Down

0 comments on commit f067943

Please sign in to comment.