From 0c44e73a780566e236876a7dec6c1fa75c36405b Mon Sep 17 00:00:00 2001 From: Jonas Platte Date: Fri, 3 Apr 2020 18:22:52 +0200 Subject: [PATCH] Bump js_int, add regression test The version bump fixes an issue where `UInt`s or `Duration`s in the query string would fail to deserialize --- Cargo.toml | 2 +- src/r0/sync/sync_events.rs | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 06fccb94..8258b075 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,7 +14,7 @@ edition = "2018" [dependencies] http = "0.2.1" -js_int = { version = "0.1.3", features = ["serde"] } +js_int = { version = "0.1.4", features = ["serde"] } ruma-api = "0.15.0" ruma-events = "0.18.0" ruma-identifiers = "0.14.1" diff --git a/src/r0/sync/sync_events.rs b/src/r0/sync/sync_events.rs index cd5740ff..c7357b1b 100644 --- a/src/r0/sync/sync_events.rs +++ b/src/r0/sync/sync_events.rs @@ -359,4 +359,32 @@ mod tests { assert!(query.contains("set_presence=offline")); assert!(query.contains("timeout=30000")) } + + #[test] + fn deserialize_sync_request_with_query_params() { + let uri = http::Uri::builder() + .scheme("https") + .authority("matrix.org") + .path_and_query("/_matrix/client/r0/sync?filter=myfilter&since=myts&full_state=false&set_presence=offline&timeout=5000") + .build() + .unwrap(); + + let req: Request = http::Request::builder() + .uri(uri) + .body(Vec::::new()) + .unwrap() + .try_into() + .unwrap(); + + match req.filter { + Some(Filter::FilterId(id)) if id == "myfilter" => {} + _ => { + panic!("Not the expected filter ID."); + } + } + assert_eq!(req.since, Some("myts".into())); + assert_eq!(req.full_state, false); + assert_eq!(req.set_presence, SetPresence::Offline); + assert_eq!(req.timeout, Some(Duration::from_millis(5000))); + } }