[FEATURE] Add unit tests #7
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -22,7 +22,7 @@ checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9"
|
||||
|
||||
[[package]]
|
||||
name = "loadstar"
|
||||
version = "0.0.4"
|
||||
version = "0.0.5"
|
||||
dependencies = [
|
||||
"tiny_http",
|
||||
]
|
||||
|
@ -2,7 +2,7 @@
|
||||
name = "loadstar"
|
||||
description = "A simple web framework for rust"
|
||||
repository = "https://git.kjan.de/jank/loadstar"
|
||||
version = "0.0.4"
|
||||
version = "0.0.5"
|
||||
license = "GPL-3.0-only"
|
||||
edition = "2021"
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
use tiny_http::Request;
|
||||
|
||||
|
||||
pub trait Url {
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user