aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/serve_request.rs27
1 files changed, 26 insertions, 1 deletions
diff --git a/tests/serve_request.rs b/tests/serve_request.rs
index 7419ab1..f48065f 100644
--- a/tests/serve_request.rs
+++ b/tests/serve_request.rs
@@ -6,6 +6,7 @@ use fixtures::{port, tmpdir, Error, DIRECTORIES, FILES};
use rstest::rstest;
use select::document::Document;
use select::node::Node;
+use std::io::BufReader;
use std::process::{Command, Stdio};
use std::thread::sleep;
use std::time::Duration;
@@ -55,7 +56,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 +67,24 @@ fn serves_requests_with_non_default_port(tmpdir: TempDir, port: u16) -> Result<(
Ok(())
}
+
+#[rstest]
+fn serves_requests_custom_index_notice(tmpdir: TempDir) -> Result<(), Error> {
+ let mut child = Command::cargo_bin("miniserve")?
+ .arg("--index=not.html")
+ .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(())
+}