From a97edcab822aeda863ba01e8b4cb70f99d0bae49 Mon Sep 17 00:00:00 2001 From: Buck Doyle Date: Sat, 28 Oct 2023 18:30:42 -0400 Subject: [PATCH] ud: Add filter to remove voicepassless teams --- unmnemonic_devices_vrs/src/routes/teams.rs | 2 +- .../tests/api/fixtures/teams-with-no-voicepass.sql | 9 +++++++++ unmnemonic_devices_vrs/tests/api/teams.rs | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 unmnemonic_devices_vrs/tests/api/fixtures/teams-with-no-voicepass.sql diff --git a/unmnemonic_devices_vrs/src/routes/teams.rs b/unmnemonic_devices_vrs/src/routes/teams.rs index 91ac1c96..91c95347 100644 --- a/unmnemonic_devices_vrs/src/routes/teams.rs +++ b/unmnemonic_devices_vrs/src/routes/teams.rs @@ -29,7 +29,7 @@ pub struct Team { #[axum_macros::debug_handler] pub async fn get_teams(Key(key): Key, State(state): State) -> impl IntoResponse { let teams = sqlx::query_as::<_, Team>( - "SELECT *, ARRAY[]::VARCHAR[] AS excerpts, ARRAY[]::VARCHAR[] AS answers FROM teams", + "SELECT *, ARRAY[]::VARCHAR[] AS excerpts, ARRAY[]::VARCHAR[] AS answers FROM teams WHERE voicepass IS NOT NULL", ) .fetch_all(&state.db) .await diff --git a/unmnemonic_devices_vrs/tests/api/fixtures/teams-with-no-voicepass.sql b/unmnemonic_devices_vrs/tests/api/fixtures/teams-with-no-voicepass.sql new file mode 100644 index 00000000..9b020f21 --- /dev/null +++ b/unmnemonic_devices_vrs/tests/api/fixtures/teams-with-no-voicepass.sql @@ -0,0 +1,9 @@ +INSERT INTO + public.teams (id, name, inserted_at, updated_at) +VALUES + ( + '00000000-db52-4c99-985f-337e266f7832', + 'hmm', + now(), + now() + ); \ No newline at end of file diff --git a/unmnemonic_devices_vrs/tests/api/teams.rs b/unmnemonic_devices_vrs/tests/api/teams.rs index f9099c6a..5798d31a 100644 --- a/unmnemonic_devices_vrs/tests/api/teams.rs +++ b/unmnemonic_devices_vrs/tests/api/teams.rs @@ -9,7 +9,7 @@ use unmnemonic_devices_vrs::InjectableServices; use wiremock::matchers::{body_string, method, path_regex}; use wiremock::{Mock, MockServer, ResponseTemplate}; -#[sqlx::test(fixtures("schema", "teams"))] +#[sqlx::test(fixtures("schema", "teams", "teams-with-no-voicepass"))] async fn teams_show_gathers_team_voicepasses(db: PgPool) { let response = get(db, "/teams", false) .await