diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/serve_request.rs | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/tests/serve_request.rs b/tests/serve_request.rs index 7419ab1..064e196 100644 --- a/tests/serve_request.rs +++ b/tests/serve_request.rs @@ -55,7 +55,10 @@ fn serves_requests_with_non_default_port(tmpdir: TempDir, port: u16) -> Result<( .error_for_status()?; let dir_body_parsed = Document::from_read(dir_body)?; for &file in FILES { - assert!(dir_body_parsed.find(|x: &Node| x.text() == file).next().is_some()); + assert!(dir_body_parsed + .find(|x: &Node| x.text() == file) + .next() + .is_some()); } } @@ -63,3 +66,26 @@ fn serves_requests_with_non_default_port(tmpdir: TempDir, port: u16) -> Result<( Ok(()) } + +#[rstest] +fn serves_requests_custom_index_notice(tmpdir: TempDir, port: u16) -> Result<(), Error> { + let mut child = Command::cargo_bin("miniserve")? + .arg("--index=not.html") + .arg("-p") + .arg(port.to_string()) + .arg(tmpdir.path()) + .stdout(Stdio::piped()) + .spawn()?; + + sleep(Duration::from_secs(1)); + + child.kill()?; + let output = child.wait_with_output().expect("Failed to read stdout"); + let all_text = String::from_utf8(output.stdout); + + assert!(all_text + .unwrap() + .contains("The provided index file could not be found")); + + Ok(()) +} |