Add tests testing failing Outgoing derive for query fields

This commit is contained in:
Devin Ragotzy 2020-08-06 16:12:52 -04:00 committed by Jonas Platte
parent 5103baeb4b
commit 7e3ebff089
2 changed files with 36 additions and 7 deletions

View File

@ -14,18 +14,12 @@ pub struct IncomingThing<T> {
} }
#[allow(unused)] #[allow(unused)]
#[derive(Copy, Clone, Debug, serde::Deserialize, serde::Serialize)] #[derive(Copy, Clone, Debug, Outgoing, serde::Serialize)]
pub struct OtherThing<'t> { pub struct OtherThing<'t> {
some: &'t str, some: &'t str,
t: &'t [u8], t: &'t [u8],
} }
#[derive(Clone, Debug, serde::Deserialize, serde::Serialize)]
pub struct IncomingOtherThing {
some: String,
t: Vec<u8>,
}
#[derive(Outgoing)] #[derive(Outgoing)]
#[incoming_no_deserialize] #[incoming_no_deserialize]
pub struct FakeRequest<'a, T> { pub struct FakeRequest<'a, T> {
@ -37,6 +31,7 @@ pub struct FakeRequest<'a, T> {
pub recursive: &'a [Thing<'a, T>], pub recursive: &'a [Thing<'a, T>],
pub option: Option<&'a [u8]>, pub option: Option<&'a [u8]>,
pub depth: Option<&'a [(&'a str, &'a str)]>, pub depth: Option<&'a [(&'a str, &'a str)]>,
pub arc_type: std::sync::Arc<&'a str>,
} }
#[derive(Outgoing)] #[derive(Outgoing)]

View File

@ -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<usize>,
/// 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: { }
}
}