Compare commits

...

3 Commits

Author SHA1 Message Date
4f0180321c Merge pull request '[FEATURE] Add unit tests' (#7) from feature/tests into main
All checks were successful
Cargo Build & Test / Test publish (push) Successful in 10s
Reviewed-on: #7
2024-08-20 13:28:06 +00:00
93d49e8a57
Update version
All checks were successful
Cargo Build & Test / Tests (pull_request) Successful in 11s
Cargo Build & Test / Test publish (pull_request) Successful in 10s
Cargo Build & Test / check-cargo-version (pull_request) Successful in 5s
2024-08-20 15:27:35 +02:00
55c023f504
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
2024-08-20 15:24:32 +02:00
3 changed files with 21 additions and 4 deletions

2
Cargo.lock generated

@ -22,7 +22,7 @@ checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9"
[[package]] [[package]]
name = "loadstar" name = "loadstar"
version = "0.0.4" version = "0.0.5"
dependencies = [ dependencies = [
"tiny_http", "tiny_http",
] ]

@ -2,7 +2,7 @@
name = "loadstar" name = "loadstar"
description = "A simple web framework for rust" description = "A simple web framework for rust"
repository = "https://git.kjan.de/jank/loadstar" repository = "https://git.kjan.de/jank/loadstar"
version = "0.0.4" version = "0.0.5"
license = "GPL-3.0-only" license = "GPL-3.0-only"
edition = "2021" edition = "2021"

@ -1,8 +1,7 @@
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;
} }
impl Url for Request { 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");
}
}