diff options
Diffstat (limited to 'tests/navigation.rs')
-rw-r--r-- | tests/navigation.rs | 38 |
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. |