From 71e537d123d48d307d3ad5a046af343931a52464 Mon Sep 17 00:00:00 2001 From: Devin Ragotzy Date: Wed, 29 Jul 2020 08:43:22 -0400 Subject: [PATCH] Move move-value test decl into logical mods for each --- ruma-api/tests/ui/03-move-value.rs | 84 +++++++++++++++--------------- 1 file changed, 43 insertions(+), 41 deletions(-) diff --git a/ruma-api/tests/ui/03-move-value.rs b/ruma-api/tests/ui/03-move-value.rs index 0321fdef..0832f4bd 100644 --- a/ruma-api/tests/ui/03-move-value.rs +++ b/ruma-api/tests/ui/03-move-value.rs @@ -1,49 +1,51 @@ -use ruma_api::ruma_api; -use ruma_identifiers::UserId; +// This tests that the "body" fields are moved after all other fields because they +// consume the request/response. -#[derive(Clone, Debug, serde::Deserialize, serde::Serialize)] -pub struct Foo; - -ruma_api! { - metadata: { - description: "Does something.", - method: POST, - name: "my_endpoint", - path: "/_matrix/foo/:bar/", - rate_limited: false, - requires_authentication: false, - } - - request: { - #[ruma_api(body)] - pub q2: Foo, - - #[ruma_api(path)] - pub bar: String, - - #[ruma_api(query)] - pub baz: UserId, - - #[ruma_api(header = CONTENT_TYPE)] - pub world: String, - } - - response: { - #[ruma_api(raw_body)] - pub q2: Vec, - - #[ruma_api(header = CONTENT_TYPE)] - pub world: String, - } -} - -mod raw_body_request { +mod newtype_body { use ruma_api::ruma_api; use ruma_identifiers::UserId; #[derive(Clone, Debug, serde::Deserialize, serde::Serialize)] pub struct Foo; + ruma_api! { + metadata: { + description: "Does something.", + method: POST, + name: "my_endpoint", + path: "/_matrix/foo/:bar/", + rate_limited: false, + requires_authentication: false, + } + + request: { + #[ruma_api(body)] + pub q2: Foo, + + #[ruma_api(path)] + pub bar: String, + + #[ruma_api(query)] + pub baz: UserId, + + #[ruma_api(header = CONTENT_TYPE)] + pub world: String, + } + + response: { + #[ruma_api(body)] + pub q2: Foo, + + #[ruma_api(header = CONTENT_TYPE)] + pub world: String, + } + } +} + +mod newtype_raw_body { + use ruma_api::ruma_api; + use ruma_identifiers::UserId; + ruma_api! { metadata: { description: "Does something.", @@ -69,8 +71,8 @@ mod raw_body_request { } response: { - #[ruma_api(body)] - pub q2: Foo, + #[ruma_api(raw_body)] + pub q2: Vec, #[ruma_api(header = CONTENT_TYPE)] pub world: String,