Skip to content

Commit

Permalink
Fix TestDB setup
Browse files Browse the repository at this point in the history
  • Loading branch information
Jurshsmith committed Sep 15, 2023
1 parent 957f841 commit a6671ef
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
3 changes: 2 additions & 1 deletion .env.sample
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# db
TEST_DATABASE_URL=postgres://postgres:postgres@localhost:5432/chaindexing_tests
TEST_DATABASE_URL=postgres://postgres:postgres@localhost:5432/chaindexing_tests
SETUP_TEST_DB=true
6 changes: 0 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 9 additions & 1 deletion chaindexing-tests/src/main.rs
Original file line number Diff line number Diff line change
@@ -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;
}

0 comments on commit a6671ef

Please sign in to comment.