client-api: Move tests in get_public_rooms into tests module

This commit is contained in:
Jonas Platte 2020-08-08 21:07:35 +02:00
parent f37fc6845f
commit c39e9f5779
No known key found for this signature in database
GPG Key ID: 7D261D771D915378

View File

@ -51,10 +51,19 @@ ruma_api! {
error: crate::Error error: crate::Error
} }
#[test] #[cfg(test)]
fn construct_request_from_refs() { mod tests {
use std::convert::TryInto;
use js_int::uint;
use ruma_api::Endpoint as _;
use super::{Request, Response};
#[test]
fn construct_request_from_refs() {
let req: http::Request<Vec<u8>> = let req: http::Request<Vec<u8>> =
Request { limit: Some(js_int::uint!(10)), since: Some("hello"), server: Some("address") } Request { limit: Some(uint!(10)), since: Some("hello"), server: Some("address") }
.try_into_http_request("https://homeserver.tld", Some("auth_tok")) .try_into_http_request("https://homeserver.tld", Some("auth_tok"))
.unwrap(); .unwrap();
@ -65,17 +74,15 @@ fn construct_request_from_refs() {
assert!(query.contains("since=hello")); assert!(query.contains("since=hello"));
assert!(query.contains("limit=10")); assert!(query.contains("limit=10"));
assert!(query.contains("server=address")); assert!(query.contains("server=address"));
} }
#[test]
fn construct_response_from_refs() {
use std::convert::TryInto;
#[test]
fn construct_response_from_refs() {
let res: http::Response<Vec<u8>> = Response { let res: http::Response<Vec<u8>> = Response {
chunk: vec![], chunk: vec![],
next_batch: Some("next_batch_token".into()), next_batch: Some("next_batch_token".into()),
prev_batch: Some("prev_batch_token".into()), prev_batch: Some("prev_batch_token".into()),
total_room_count_estimate: Some(js_int::uint!(10)), total_room_count_estimate: Some(uint!(10)),
} }
.try_into() .try_into()
.unwrap(); .unwrap();
@ -84,4 +91,5 @@ fn construct_response_from_refs() {
String::from_utf8_lossy(res.body()), String::from_utf8_lossy(res.body()),
r#"{"chunk":[],"next_batch":"next_batch_token","prev_batch":"prev_batch_token","total_room_count_estimate":10}"# r#"{"chunk":[],"next_batch":"next_batch_token","prev_batch":"prev_batch_token","total_room_count_estimate":10}"#
); );
}
} }