From cad685bb47f60a651d1a80725ee9fe4e6b1edad1 Mon Sep 17 00:00:00 2001 From: perf3ct Date: Thu, 19 Jun 2025 00:03:07 +0000 Subject: [PATCH] fix(tests): try to fix the auto_resume_tests yet again for integration tests --- .github/workflows/test-integration.yml | 14 ++++++++++++++ tests/auto_resume_tests.rs | 6 +++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test-integration.yml b/.github/workflows/test-integration.yml index 61c74f8..2a14d67 100644 --- a/.github/workflows/test-integration.yml +++ b/.github/workflows/test-integration.yml @@ -88,6 +88,20 @@ jobs: sleep 2 done + - name: Wait for PostgreSQL to be ready + run: | + until pg_isready -h localhost -p 5432 -U postgres; do + echo "Waiting for PostgreSQL..." + sleep 1 + done + echo "PostgreSQL is ready!" + + - name: Verify database connection + run: | + echo "Testing database connection..." + PGPASSWORD=postgres psql -h localhost -p 5432 -U postgres -d readur_test -c "SELECT version();" + echo "Database connection successful!" + - name: Run integration tests run: | cargo test --test '*' -- --test-threads=1 diff --git a/tests/auto_resume_tests.rs b/tests/auto_resume_tests.rs index b142f08..5d997b8 100644 --- a/tests/auto_resume_tests.rs +++ b/tests/auto_resume_tests.rs @@ -27,8 +27,12 @@ use readur::{ /// Create a test app state async fn create_test_app_state() -> Arc { + let database_url = std::env::var("TEST_DATABASE_URL") + .or_else(|_| std::env::var("DATABASE_URL")) + .unwrap_or_else(|_| "postgres://postgres:postgres@localhost:5432/readur_test".to_string()); + let config = Config { - database_url: "sqlite::memory:".to_string(), + database_url, server_address: "127.0.0.1:8080".to_string(), jwt_secret: "test_secret".to_string(), upload_path: "/tmp/test_uploads".to_string(),