aboutsummaryrefslogtreecommitdiffstats
path: root/tests/raw.rs
diff options
context:
space:
mode:
authorSven-Hendrik Haase <svenstaro@gmail.com>2023-03-01 02:38:23 +0000
committerGitHub <noreply@github.com>2023-03-01 02:38:23 +0000
commita93170d0e4cb80266da696b827e6ee21bacc5858 (patch)
tree74ec1263d385dd01107dd839fe0e73960ed24124 /tests/raw.rs
parentMerge pull request #1045 from svenstaro/dependabot/cargo/clap_mangen-0.2.9 (diff)
parentAdded tests and small fixes (diff)
downloadminiserve-a93170d0e4cb80266da696b827e6ee21bacc5858.tar.gz
miniserve-a93170d0e4cb80266da696b827e6ee21bacc5858.zip
Merge pull request #1043 from Yusuto/wget-fix
Fix the wget footer
Diffstat (limited to 'tests/raw.rs')
-rw-r--r--tests/raw.rs22
1 files changed, 19 insertions, 3 deletions
diff --git a/tests/raw.rs b/tests/raw.rs
index f212f58..95100d2 100644
--- a/tests/raw.rs
+++ b/tests/raw.rs
@@ -11,7 +11,16 @@ use select::predicate::Class;
use select::predicate::Name;
/// The footer displays the correct wget command to download the folder recursively
-#[rstest(depth, dir, case(0, ""), case(2, "very/deeply/nested/"))]
+// This test can't test all aspects of the wget footer,
+// a more detailed unit test is available
+#[rstest(
+ depth,
+ dir,
+ case(0, ""),
+ case(1, "dira/"),
+ case(2, "very/deeply/"),
+ case(3, "very/deeply/nested/")
+)]
fn ui_displays_wget_element(
depth: u8,
dir: &str,
@@ -32,11 +41,18 @@ fn ui_displays_wget_element(
.next()
.unwrap()
.text();
+ let cut_dirs = match depth {
+ // Put all the files in a folder of this name
+ 0 => format!(" -P 'localhost:{}'", server.port()),
+ 1 => String::new(),
+ // Avoids putting the files in excessive directories
+ x => format!(" --cut-dirs={}", x - 1),
+ };
assert_eq!(
wget_url,
format!(
- "wget -r -c -nH -np --cut-dirs={} -R \"index.html*\" \"{}{}?raw=true\"",
- depth,
+ "wget -rcnHp -R 'index.html*'{} '{}{}?raw=true'",
+ cut_dirs,
server.url(),
dir
)