Add tests to request
Some checks failed
Cargo Build & Test / Tests (pull_request) Successful in 9s
Cargo Build & Test / Test publish (pull_request) Successful in 9s
Cargo Build & Test / check-cargo-version (pull_request) Failing after 5s

This commit is contained in:
Jan Gleytenhoover 2024-08-20 15:24:32 +02:00
parent 3640d8c226
commit 55c023f504
Signed by: jank
GPG Key ID: B267751B8AE29EFE

@ -1,6 +1,5 @@
use tiny_http::Request; use tiny_http::Request;
pub trait Url { pub trait Url {
fn get_url_without_parameters(&self) -> String; fn get_url_without_parameters(&self) -> String;
} }
@ -11,3 +10,21 @@ impl Url for Request {
} }
} }
#[cfg(test)]
mod tests {
use crate::entities::request::*;
use tiny_http::{Request, TestRequest};
#[test]
fn test_get_url_without_parameters() {
let request = Request::from(TestRequest::new().with_path("/test?key=value"));
let actual = request.get_url_without_parameters();
assert_eq!(actual, "/test");
let request2 = Request::from(TestRequest::new().with_path("/test2"));
assert_eq!(request2.get_url_without_parameters(), "/test2");
}
}