Skip to content

Commit

Permalink
fixed test execution feature flags
Browse files Browse the repository at this point in the history
  • Loading branch information
meuter committed Apr 7, 2024
1 parent a57825b commit 6740941
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 14 deletions.
7 changes: 5 additions & 2 deletions tests/test_crud.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ macro_rules! test_crud {
mod test_crud {
use super::*;

#[cfg(feature = "mysql")]
mod mysql {
use super::*;
use sqlx::MySqlPool;
Expand All @@ -117,7 +118,8 @@ mod test_crud {
});
}

mod pgstore {
#[cfg(feature = "postgres")]
mod postgres {
use super::*;
use sqlx::PgPool;

Expand All @@ -128,7 +130,8 @@ mod test_crud {
});
}

mod sqlitestore {
#[cfg(feature = "sqlite")]
mod sqlite {
use super::*;
use sqlx::SqlitePool;

Expand Down
26 changes: 14 additions & 12 deletions tests/test_rest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ use std::error::Error;
#[macro_export]
macro_rules! test_rest {
($db: block) => {
#[cfg(feature = "axum")]
async fn get_store_with_sample_data(
) -> Result<impl Clone + Crud<Todo> + IntoAxumRouter, Box<dyn Error>> {
let pool = $db;
Expand All @@ -23,7 +22,7 @@ macro_rules! test_rest {
Ok(store)
}

#[cfg(feature = "axum")]
#[cfg_attr(not(feature = "integration_tests"), ignore)]
#[serial]
#[tokio::test]
async fn get_ok() {
Expand All @@ -37,7 +36,7 @@ macro_rules! test_rest {
assert_eq!(actual, expected);
}

#[cfg(feature = "axum")]
#[cfg_attr(not(feature = "integration_tests"), ignore)]
#[serial]
#[tokio::test]
async fn get_not_found() {
Expand All @@ -46,7 +45,7 @@ macro_rules! test_rest {
server.get("/23").await.assert_status(StatusCode::NOT_FOUND);
}

#[cfg(feature = "axum")]
#[cfg_attr(not(feature = "integration_tests"), ignore)]
#[serial]
#[tokio::test]
async fn list() {
Expand All @@ -60,7 +59,7 @@ macro_rules! test_rest {
assert_eq!(actual, expected);
}

#[cfg(feature = "axum")]
#[cfg_attr(not(feature = "integration_tests"), ignore)]
#[serial]
#[tokio::test]
async fn post() {
Expand All @@ -78,7 +77,7 @@ macro_rules! test_rest {
assert_eq!(actual, expected);
}

#[cfg(feature = "axum")]
#[cfg_attr(not(feature = "integration_tests"), ignore)]
#[serial]
#[tokio::test]
async fn put() {
Expand All @@ -99,7 +98,7 @@ macro_rules! test_rest {
assert_eq!(actual, expected);
}

#[cfg(feature = "axum")]
#[cfg_attr(not(feature = "integration_tests"), ignore)]
#[serial]
#[tokio::test]
async fn put_with_id() {
Expand All @@ -116,7 +115,7 @@ macro_rules! test_rest {
assert_eq!(actual, expected);
}

#[cfg(feature = "axum")]
#[cfg_attr(not(feature = "integration_tests"), ignore)]
#[serial]
#[tokio::test]
async fn delete_ok() {
Expand All @@ -129,7 +128,7 @@ macro_rules! test_rest {
// assert_eq!(before, after + 1);
}

#[cfg(feature = "axum")]
#[cfg_attr(not(feature = "integration_tests"), ignore)]
#[serial]
#[tokio::test]
async fn delete_not_found() {
Expand All @@ -141,7 +140,7 @@ macro_rules! test_rest {
.assert_status(StatusCode::NOT_FOUND);
}

#[cfg(feature = "axum")]
#[cfg_attr(not(feature = "integration_tests"), ignore)]
#[serial]
#[tokio::test]
async fn delete_all() {
Expand All @@ -163,6 +162,7 @@ macro_rules! test_rest {
mod test_rest {
use super::*;

#[cfg(feature = "mysql")]
mod mysql {
use super::*;
use sqlx::MySqlPool;
Expand All @@ -174,7 +174,8 @@ mod test_rest {
});
}

mod pgstore {
#[cfg(feature = "postgres")]
mod postgres {
use super::*;
use sqlx::PgPool;

Expand All @@ -185,7 +186,8 @@ mod test_rest {
});
}

mod sqlitestore {
#[cfg(feature = "sqlite")]
mod sqlite {
use super::*;
use sqlx::SqlitePool;

Expand Down

0 comments on commit 6740941

Please sign in to comment.