From 7e3ebff08942192f70df925aa60fa4428ddd2963 Mon Sep 17 00:00:00 2001 From: Devin Ragotzy Date: Thu, 6 Aug 2020 16:12:52 -0400 Subject: [PATCH] Add tests testing failing Outgoing derive for query fields --- ruma-api/tests/outgoing.rs | 9 ++------ ruma-api/tests/ruma_api_lifetime.rs | 34 +++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 7 deletions(-) diff --git a/ruma-api/tests/outgoing.rs b/ruma-api/tests/outgoing.rs index 9d7d609a..94699b0c 100644 --- a/ruma-api/tests/outgoing.rs +++ b/ruma-api/tests/outgoing.rs @@ -14,18 +14,12 @@ pub struct IncomingThing { } #[allow(unused)] -#[derive(Copy, Clone, Debug, serde::Deserialize, serde::Serialize)] +#[derive(Copy, Clone, Debug, Outgoing, serde::Serialize)] pub struct OtherThing<'t> { some: &'t str, t: &'t [u8], } -#[derive(Clone, Debug, serde::Deserialize, serde::Serialize)] -pub struct IncomingOtherThing { - some: String, - t: Vec, -} - #[derive(Outgoing)] #[incoming_no_deserialize] pub struct FakeRequest<'a, T> { @@ -37,6 +31,7 @@ pub struct FakeRequest<'a, T> { pub recursive: &'a [Thing<'a, T>], pub option: Option<&'a [u8]>, pub depth: Option<&'a [(&'a str, &'a str)]>, + pub arc_type: std::sync::Arc<&'a str>, } #[derive(Outgoing)] diff --git a/ruma-api/tests/ruma_api_lifetime.rs b/ruma-api/tests/ruma_api_lifetime.rs index 957d0131..caba75a3 100644 --- a/ruma-api/tests/ruma_api_lifetime.rs +++ b/ruma-api/tests/ruma_api_lifetime.rs @@ -121,3 +121,37 @@ mod full_request_response_with_query_map { } } } + +mod query_fields { + ruma_api::ruma_api! { + metadata: { + description: "Get the list of rooms in this homeserver's public directory.", + method: GET, + name: "get_public_rooms", + path: "/_matrix/client/r0/publicRooms", + rate_limited: false, + requires_authentication: false, + } + + request: { + /// Limit for the number of results to return. + #[serde(skip_serializing_if = "Option::is_none")] + #[ruma_api(query)] + pub limit: Option, + + /// Pagination token from a previous request. + #[serde(skip_serializing_if = "Option::is_none")] + #[ruma_api(query)] + pub since: Option<&'a str>, + + /// The server to fetch the public room lists from. + /// + /// `None` means the server this request is sent to. + #[serde(skip_serializing_if = "Option::is_none")] + #[ruma_api(query)] + pub server: Option<&'a str>, + } + + response: { } + } +}