From 029cf75aed527d2b9476bfcd1da06b4f60b6b413 Mon Sep 17 00:00:00 2001 From: Manuel Carrer Date: Fri, 14 Jun 2024 16:04:50 +0200 Subject: [PATCH] Deserialize ingestor response --- lard_tests/tests/common/mod.rs | 8 ++++++++ lard_tests/tests/ingestion.rs | 8 +++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/lard_tests/tests/common/mod.rs b/lard_tests/tests/common/mod.rs index 95277959..28af25ca 100644 --- a/lard_tests/tests/common/mod.rs +++ b/lard_tests/tests/common/mod.rs @@ -16,6 +16,14 @@ use lard_ingestion::{PgConnectionPool, PooledPgConn}; const CONNECT_STRING: &str = "host=localhost user=postgres dbname=postgres password=postgres"; pub const PARAMCONV_CSV: &str = "../ingestion/resources/paramconversions.csv"; +#[derive(Debug, Deserialize)] +pub struct IngestorResponse { + pub message: String, + pub message_id: usize, + pub res: u8, + pub retry: bool, +} + #[derive(Debug, Deserialize)] pub struct StationsResponse { pub tseries: Vec, diff --git a/lard_tests/tests/ingestion.rs b/lard_tests/tests/ingestion.rs index e33bd536..84df8814 100644 --- a/lard_tests/tests/ingestion.rs +++ b/lard_tests/tests/ingestion.rs @@ -63,7 +63,6 @@ async fn test_kldata_endpoint() { let test = async { let station_id = 1800; - let client = reqwest::Client::new(); let obsinn_msg = format!( "kldata/nationalnr={}/type=508/messageid=23 TA,TWD(0,0) @@ -77,15 +76,18 @@ TA,TWD(0,0) station_id ); + let client = reqwest::Client::new(); let resp = client .post("http://localhost:3001/kldata") .body(obsinn_msg) .send() .await .unwrap(); - println!("\ningestion resp: {}", resp.text().await.unwrap()); - // TODO: do something else with the response + let json: common::IngestorResponse = resp.json().await.unwrap(); + + assert_eq!(json.res, 0); + assert_eq!(json.message_id, 23) }; tokio::select! {