From 55c023f50495cd0f0cb3d6dd6ef5ec3355f6f85d Mon Sep 17 00:00:00 2001 From: Jan Klattenhoff Date: Tue, 20 Aug 2024 15:24:32 +0200 Subject: [PATCH 1/2] Add tests to request --- src/entities/request.rs | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) 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"); + } +} -- 2.45.2 From 93d49e8a57a70d6d304808698ba0bfcb7c7605a7 Mon Sep 17 00:00:00 2001 From: Jan Klattenhoff Date: Tue, 20 Aug 2024 15:27:35 +0200 Subject: [PATCH 2/2] Update version --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5686fde..35b5cde 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -22,7 +22,7 @@ checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" [[package]] name = "loadstar" -version = "0.0.4" +version = "0.0.5" dependencies = [ "tiny_http", ] diff --git a/Cargo.toml b/Cargo.toml index 678a032..d234736 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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" -- 2.45.2