From 2103ea0ed4df223b238dda96f142814692ed861d Mon Sep 17 00:00:00 2001 From: jikstra Date: Wed, 29 Dec 2021 04:10:24 +0100 Subject: Implement --route-prefix to set specific route prefix --- tests/serve_request.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'tests') diff --git a/tests/serve_request.rs b/tests/serve_request.rs index ec2c978..1491be9 100644 --- a/tests/serve_request.rs +++ b/tests/serve_request.rs @@ -260,3 +260,18 @@ fn serve_index_instead_of_404_in_spa_mode( Ok(()) } + +#[rstest] +fn serves_requests_with_path_prefix( + #[with(["--route-prefix", "foobar"])] server: TestServer, +) -> Result<(), Error> { + let url_without_route = server.url(); + let status = reqwest::blocking::get(url_without_route)?.status(); + assert_eq!(status, StatusCode::NOT_FOUND); + + let url_with_route = format!("{}{}", server.url(), "foobar"); + let status = reqwest::blocking::get(url_with_route)?.status(); + assert_eq!(status, StatusCode::OK); + + Ok(()) +} -- cgit v1.2.3 From 0e6adbb3b53147f2e78a907909f6c470190ebaf3 Mon Sep 17 00:00:00 2001 From: Ali MJ Al-Nasrawy Date: Sun, 6 Feb 2022 14:48:33 +0300 Subject: Fix route_prefix for css and favicon --- tests/bind.rs | 1 + tests/serve_request.rs | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'tests') diff --git a/tests/bind.rs b/tests/bind.rs index 1c816f0..0fa914e 100644 --- a/tests/bind.rs +++ b/tests/bind.rs @@ -53,6 +53,7 @@ fn bind_ipv4_ipv6( #[case(&["-i", "0.0.0.0"])] #[case(&["-i", "::", "-i", "0.0.0.0"])] #[case(&["--random-route"])] +#[case(&["--route-prefix", "/prefix"])] fn validate_printed_urls(tmpdir: TempDir, port: u16, #[case] args: &[&str]) -> Result<(), Error> { let mut child = Command::cargo_bin("miniserve")? .arg(tmpdir.path()) diff --git a/tests/serve_request.rs b/tests/serve_request.rs index 1491be9..d66ffd4 100644 --- a/tests/serve_request.rs +++ b/tests/serve_request.rs @@ -262,14 +262,14 @@ fn serve_index_instead_of_404_in_spa_mode( } #[rstest] -fn serves_requests_with_path_prefix( - #[with(["--route-prefix", "foobar"])] server: TestServer, -) -> Result<(), Error> { +#[case(server(&["--route-prefix", "foobar"]))] +#[case(server(&["--route-prefix", "/foobar/"]))] +fn serves_requests_with_route_prefix(#[case] server: TestServer) -> Result<(), Error> { let url_without_route = server.url(); let status = reqwest::blocking::get(url_without_route)?.status(); assert_eq!(status, StatusCode::NOT_FOUND); - let url_with_route = format!("{}{}", server.url(), "foobar"); + let url_with_route = server.url().join("foobar")?; let status = reqwest::blocking::get(url_with_route)?.status(); assert_eq!(status, StatusCode::OK); -- cgit v1.2.3