aboutsummaryrefslogtreecommitdiffstats
path: root/tests/navigation.rs
diff options
context:
space:
mode:
authorSven-Hendrik Haase <svenstaro@gmail.com>2025-02-07 12:48:50 +0000
committerGitHub <noreply@github.com>2025-02-07 12:48:50 +0000
commit77b1c1cd0bfab5d4dc5e0994050fabd4a19cdd0f (patch)
tree0b9e157598d2361397ee09e7f196938d284c48f9 /tests/navigation.rs
parentchore: clean up (diff)
parentAdd CHANGELOG entry for #1473 (diff)
downloadminiserve-77b1c1cd0bfab5d4dc5e0994050fabd4a19cdd0f.tar.gz
miniserve-77b1c1cd0bfab5d4dc5e0994050fabd4a19cdd0f.zip
Merge branch 'master' into upload-progress-bar
Diffstat (limited to 'tests/navigation.rs')
-rw-r--r--tests/navigation.rs38
1 files changed, 20 insertions, 18 deletions
diff --git a/tests/navigation.rs b/tests/navigation.rs
index 8c21beb..1bd8e81 100644
--- a/tests/navigation.rs
+++ b/tests/navigation.rs
@@ -1,24 +1,26 @@
-mod fixtures;
-mod utils;
+use std::process::{Command, Stdio};
-use fixtures::{server, Error, TestServer, DEEPLY_NESTED_FILE, DIRECTORIES};
use pretty_assertions::{assert_eq, assert_ne};
use rstest::rstest;
use select::document::Document;
-use std::process::{Command, Stdio};
-use utils::get_link_from_text;
-use utils::get_link_hrefs_with_prefix;
-
-#[rstest(
- input,
- expected,
- case("", "/"),
- case("/dira", "/dira/"),
- case("/dirb/", "/dirb/"),
- case("/very/deeply/nested", "/very/deeply/nested/")
-)]
+
+mod fixtures;
+mod utils;
+
+use crate::fixtures::{server, Error, TestServer, DEEPLY_NESTED_FILE, DIRECTORIES};
+use crate::utils::{get_link_from_text, get_link_hrefs_with_prefix};
+
+#[rstest]
+#[case("", "/")]
+#[case("/dira", "/dira/")]
+#[case("/dirb/", "/dirb/")]
+#[case("/very/deeply/nested", "/very/deeply/nested/")]
/// Directories get a trailing slash.
-fn index_gets_trailing_slash(server: TestServer, input: &str, expected: &str) -> Result<(), Error> {
+fn index_gets_trailing_slash(
+ server: TestServer,
+ #[case] input: &str,
+ #[case] expected: &str,
+) -> Result<(), Error> {
let resp = reqwest::blocking::get(server.url().join(input)?)?;
assert!(resp.url().as_str().ends_with(expected));
@@ -52,11 +54,11 @@ fn can_navigate_into_dirs_and_back(server: TestServer) -> Result<(), Error> {
let initial_parsed = Document::from_read(initial_body)?;
for &directory in DIRECTORIES {
let dir_elem = get_link_from_text(&initial_parsed, directory).expect("Dir not found.");
- let body = reqwest::blocking::get(&format!("{base_url}{dir_elem}"))?.error_for_status()?;
+ let body = reqwest::blocking::get(format!("{base_url}{dir_elem}"))?.error_for_status()?;
let parsed = Document::from_read(body)?;
let back_link =
get_link_from_text(&parsed, "Parent directory").expect("Back link not found.");
- let resp = reqwest::blocking::get(&format!("{base_url}{back_link}"))?;
+ let resp = reqwest::blocking::get(format!("{base_url}{back_link}"))?;
// Now check that we can actually get back to the original location we came from using the
// link.