Skip to content

Commit 7c0b968

Browse files
committed
allow running postgres tests only
1 parent 3288e0e commit 7c0b968

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

database/src/pool.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,10 @@ mod tests {
306306
use std::str::FromStr;
307307

308308
use super::*;
309-
use crate::{tests::run_db_test, BenchmarkRequestStatus, Commit, CommitType, Date};
309+
use crate::{
310+
tests::{run_db_test, run_postgres_test},
311+
BenchmarkRequestStatus, Commit, CommitType, Date,
312+
};
310313

311314
/// Create a Commit
312315
fn create_commit(commit_sha: &str, time: chrono::DateTime<Utc>, r#type: CommitType) -> Commit {
@@ -378,7 +381,7 @@ mod tests {
378381

379382
#[tokio::test]
380383
async fn insert_benchmark_requests() {
381-
run_db_test(|ctx| async {
384+
run_postgres_test(|ctx| async {
382385
let db = ctx.db_client();
383386
let time = chrono::DateTime::from_str("2021-09-01T00:00:00.000Z").unwrap();
384387
let master_benchmark_request = BenchmarkRequest::create_master(

database/src/tests/mod.rs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,8 @@ impl TestContext {
113113
}
114114
}
115115

116-
/// Runs a test against an actual database.
117-
/// Checks both Postgres and SQLite.
118-
pub(crate) async fn run_db_test<F, Fut>(f: F)
116+
/// Runs a test against an actual postgres database.
117+
pub(crate) async fn run_postgres_test<F, Fut>(f: F)
119118
where
120119
F: Fn(TestContext) -> Fut,
121120
Fut: Future<Output = anyhow::Result<TestContext>>,
@@ -126,9 +125,6 @@ where
126125
let ctx = TestContext::new_postgres(&db_url).await;
127126
let ctx = f(ctx).await.expect("Postgres test failed");
128127
ctx.finish().await;
129-
// We don't want to run both postgres tests & sqlite tests as some tests
130-
// are only designed for postgres
131-
return;
132128
} else {
133129
// The github CI does not yet support running containers on Windows,
134130
// meaning that the test suite would fail.
@@ -141,7 +137,16 @@ where
141137
);
142138
}
143139
}
140+
}
144141

142+
/// Runs a test against an actual database.
143+
/// Checks both Postgres and SQLite.
144+
pub(crate) async fn run_db_test<F, Fut>(f: F)
145+
where
146+
F: Fn(TestContext) -> Fut + Clone,
147+
Fut: Future<Output = anyhow::Result<TestContext>>,
148+
{
149+
run_postgres_test(f.clone()).await;
145150
// SQLite
146151
eprintln!("Running test with SQLite");
147152
let ctx = TestContext::new_sqlite().await;

0 commit comments

Comments
 (0)