api: Add tests for make_endpoint_url
This commit is contained in:
parent
8290d712f2
commit
0b12d200eb
@ -501,7 +501,7 @@ fn select_path<'a>(
|
|||||||
mod tests {
|
mod tests {
|
||||||
use super::{
|
use super::{
|
||||||
error::IntoHttpError,
|
error::IntoHttpError,
|
||||||
select_path, AuthScheme,
|
make_endpoint_url, select_path, AuthScheme,
|
||||||
MatrixVersion::{V1_0, V1_1, V1_2},
|
MatrixVersion::{V1_0, V1_1, V1_2},
|
||||||
Metadata,
|
Metadata,
|
||||||
};
|
};
|
||||||
@ -524,6 +524,36 @@ mod tests {
|
|||||||
|
|
||||||
// TODO add test that can hook into tracing and verify the deprecation warning is emitted
|
// TODO add test that can hook into tracing and verify the deprecation warning is emitted
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn make_simple_endpoint_url() {
|
||||||
|
let meta = Metadata { added: Some(V1_0), stable_path: Some("/s"), ..BASE };
|
||||||
|
let url = make_endpoint_url(&meta, &[V1_0], "https://example.org", &[], None).unwrap();
|
||||||
|
assert_eq!(url, "https://example.org/s");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn make_endpoint_url_with_path_args() {
|
||||||
|
let meta = Metadata { added: Some(V1_0), stable_path: Some("/s/:x"), ..BASE };
|
||||||
|
let url =
|
||||||
|
make_endpoint_url(&meta, &[V1_0], "https://example.org", &[&"123"], None).unwrap();
|
||||||
|
assert_eq!(url, "https://example.org/s/123");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn make_endpoint_url_with_query() {
|
||||||
|
let meta = Metadata { added: Some(V1_0), stable_path: Some("/s/"), ..BASE };
|
||||||
|
let url =
|
||||||
|
make_endpoint_url(&meta, &[V1_0], "https://example.org", &[], Some("foo=bar")).unwrap();
|
||||||
|
assert_eq!(url, "https://example.org/s/?foo=bar");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
#[should_panic]
|
||||||
|
fn make_endpoint_url_wrong_num_path_args() {
|
||||||
|
let meta = Metadata { added: Some(V1_0), stable_path: Some("/s/:x"), ..BASE };
|
||||||
|
_ = make_endpoint_url(&meta, &[V1_0], "https://example.org", &[], None);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn select_stable() {
|
fn select_stable() {
|
||||||
let meta = Metadata { added: Some(V1_1), stable_path: Some("s"), ..BASE };
|
let meta = Metadata { added: Some(V1_1), stable_path: Some("s"), ..BASE };
|
||||||
|
Loading…
x
Reference in New Issue
Block a user