Skip to content

Commit

Permalink
Deserialize ingestor response
Browse files Browse the repository at this point in the history
  • Loading branch information
Lun4m committed Jun 14, 2024
1 parent 7938e51 commit 029cf75
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
8 changes: 8 additions & 0 deletions lard_tests/tests/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Tseries>,
Expand Down
8 changes: 5 additions & 3 deletions lard_tests/tests/ingestion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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! {
Expand Down

0 comments on commit 029cf75

Please sign in to comment.