Skip to content

Commit

Permalink
Workaround [sqlx::test] macro bug in sqlx 0.8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
praseodym committed Aug 1, 2024
1 parent 66f7583 commit 678210d
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions backend/src/polling_station/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ mod tests {

use super::*;

#[sqlx::test(fixtures(path = "../../fixtures", scripts("elections", "polling_stations")))]
#[sqlx::test(fixtures("../../fixtures/elections.sql", "../../fixtures/polling_stations.sql"))]
async fn test_polling_station_data_entry_valid(pool: SqlitePool) {
let mut request_body = DataEntryRequest {
data: PollingStationResults {
Expand Down Expand Up @@ -297,7 +297,7 @@ mod tests {
assert_eq!(row_count.count, 1);
}

#[sqlx::test(fixtures(path = "../../fixtures", scripts("elections")))]
#[sqlx::test(fixtures("../../fixtures/elections.sql"))]
async fn test_polling_station_number_unique_per_election(pool: SqlitePool) {
// Insert two unique polling stations
let _ = query!(r#"
Expand Down
6 changes: 3 additions & 3 deletions backend/tests/data_entries_integration_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use crate::utils::serve_api;

mod utils;

#[sqlx::test(fixtures(path = "../fixtures", scripts("elections", "polling_stations")))]
#[sqlx::test(fixtures("../fixtures/elections.sql", "../fixtures/polling_stations.sql"))]
async fn test_polling_station_data_entry_valid(pool: SqlitePool) {
let addr = serve_api(pool).await;

Expand Down Expand Up @@ -85,7 +85,7 @@ async fn test_polling_station_data_entry_valid(pool: SqlitePool) {
assert_eq!(response.status(), StatusCode::OK);
}

#[sqlx::test(fixtures(path = "../fixtures", scripts("elections", "polling_stations")))]
#[sqlx::test(fixtures("../fixtures/elections.sql", "../fixtures/polling_stations.sql"))]
async fn test_polling_station_data_entry_validation(pool: SqlitePool) {
let addr = serve_api(pool).await;

Expand Down Expand Up @@ -213,7 +213,7 @@ async fn test_polling_station_data_entry_invalid(pool: SqlitePool) {
);
}

#[sqlx::test(fixtures(path = "../fixtures", scripts("elections", "polling_stations")))]
#[sqlx::test(fixtures("../fixtures/elections.sql", "../fixtures/polling_stations.sql"))]
async fn test_polling_station_data_entry_only_for_existing(pool: SqlitePool) {
let addr = serve_api(pool).await;

Expand Down
4 changes: 2 additions & 2 deletions backend/tests/election_integration_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::utils::serve_api;

mod utils;

#[sqlx::test(fixtures(path = "../fixtures", scripts("elections")))]
#[sqlx::test(fixtures("../fixtures/elections.sql"))]
async fn test_election_list_works(pool: SqlitePool) {
let addr = serve_api(pool).await;

Expand All @@ -24,7 +24,7 @@ async fn test_election_list_works(pool: SqlitePool) {
assert_eq!(body.elections.len(), 2);
}

#[sqlx::test(fixtures(path = "../fixtures", scripts("elections")))]
#[sqlx::test(fixtures("../fixtures/elections.sql"))]
async fn test_election_details_works(pool: SqlitePool) {
let addr = serve_api(pool).await;

Expand Down
4 changes: 2 additions & 2 deletions backend/tests/polling_station_integration_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::utils::serve_api;

mod utils;

#[sqlx::test(fixtures(path = "../fixtures", scripts("elections", "polling_stations")))]
#[sqlx::test(fixtures("../fixtures/elections.sql", "../fixtures/polling_stations.sql"))]
async fn test_polling_station_listing_works(pool: SqlitePool) {
let addr = serve_api(pool).await;

Expand All @@ -28,7 +28,7 @@ async fn test_polling_station_listing_works(pool: SqlitePool) {
.any(|ps| ps.name == "Stembureau \"Op Rolletjes\""));
}

#[sqlx::test(fixtures(path = "../fixtures", scripts("elections", "polling_stations")))]
#[sqlx::test(fixtures("../fixtures/elections.sql", "../fixtures/polling_stations.sql"))]
async fn test_polling_station_list_invalid_election(pool: SqlitePool) {
let addr = serve_api(pool).await;
// election ID 1234 does not exist
Expand Down

0 comments on commit 678210d

Please sign in to comment.