diff --git a/src/entities/request.rs b/src/entities/request.rs index 3713c95..f0aedc9 100644 --- a/src/entities/request.rs +++ b/src/entities/request.rs @@ -1,8 +1,7 @@ use tiny_http::Request; - pub trait Url { - fn get_url_without_parameters(&self) -> String; + fn get_url_without_parameters(&self) -> String; } impl Url for Request { @@ -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"); + } +}