From a6671efb649ddd3ba34ab19d002dc13b93083997 Mon Sep 17 00:00:00 2001 From: Joshua Oladele Date: Fri, 15 Sep 2023 15:49:41 +0100 Subject: [PATCH] Fix TestDB setup --- .env.sample | 3 ++- .github/workflows/ci.yml | 6 ------ chaindexing-tests/src/main.rs | 10 +++++++++- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/.env.sample b/.env.sample index d7f2f3c..caeba3a 100644 --- a/.env.sample +++ b/.env.sample @@ -1,2 +1,3 @@ # db -TEST_DATABASE_URL=postgres://postgres:postgres@localhost:5432/chaindexing_tests \ No newline at end of file +TEST_DATABASE_URL=postgres://postgres:postgres@localhost:5432/chaindexing_tests +SETUP_TEST_DB=true \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5aa726d..7addc6b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -47,12 +47,6 @@ jobs: - uses: dtolnay/rust-toolchain@stable with: toolchain: ${{matrix.rust}} - - name: Enable type layout randomization - run: echo RUSTFLAGS=${RUSTFLAGS}\ -Zrandomize-layout >> $GITHUB_ENV - if: matrix.rust == 'nightly' - - name: Enable nightly-only tests - run: echo RUSTFLAGS=${RUSTFLAGS}\ --cfg=async_trait_nightly_testing >> $GITHUB_ENV - if: matrix.rust == 'nightly' - name: Setup Database run: cargo run -p chaindexing-tests - name: Run Tests diff --git a/chaindexing-tests/src/main.rs b/chaindexing-tests/src/main.rs index e79a0d1..a07293b 100644 --- a/chaindexing-tests/src/main.rs +++ b/chaindexing-tests/src/main.rs @@ -1,7 +1,15 @@ +use chaindexing::{ChaindexingRepo, Migratable, Repo}; use chaindexing_tests::db; -fn main() { +#[tokio::main] +async fn main() { // Run once to setup database // Useful in a CI environment running parallel tests db::setup(); + + let repo = ChaindexingRepo::new(db::database_url().as_str()); + let pool = repo.get_pool(1).await; + let mut conn = ChaindexingRepo::get_conn(&pool).await; + + repo.migrate(&mut conn).await; }