diff options
author | Sven-Hendrik Haase <svenstaro@gmail.com> | 2019-07-07 16:22:57 +0000 |
---|---|---|
committer | Sven-Hendrik Haase <svenstaro@gmail.com> | 2019-07-07 16:22:57 +0000 |
commit | 294d32ba32a9fd3b097b0582137cd477765e364f (patch) | |
tree | 7c8ec912eb2fd3e7af87b328fb3c20a17523cc08 /tests/serve_request.rs | |
parent | Bump lock file (diff) | |
download | miniserve-294d32ba32a9fd3b097b0582137cd477765e364f.tar.gz miniserve-294d32ba32a9fd3b097b0582137cd477765e364f.zip |
Also check directories in tests
Diffstat (limited to '')
-rw-r--r-- | tests/serve_request.rs | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/tests/serve_request.rs b/tests/serve_request.rs index ef346b2..a3970d7 100644 --- a/tests/serve_request.rs +++ b/tests/serve_request.rs @@ -2,9 +2,10 @@ mod fixtures; use assert_cmd::prelude::*; use assert_fs::fixture::TempDir; -use fixtures::{port, tmpdir, Error, FILES}; +use fixtures::{port, tmpdir, Error, DIRECTORIES, FILES}; use rstest::rstest; use select::document::Document; +use select::node::Node; use select::predicate::Text; use std::process::{Command, Stdio}; use std::thread::sleep; @@ -22,7 +23,7 @@ fn serves_requests_with_no_options(tmpdir: TempDir) -> Result<(), Error> { let body = reqwest::get("http://localhost:8080")?.error_for_status()?; let parsed = Document::from_read(body)?; for &file in FILES { - assert!(parsed.find(Text).any(|x| x.text() == file)); + assert!(parsed.find(|x: &Node| x.text() == file).next().is_some()); } child.kill()?; @@ -44,7 +45,19 @@ fn serves_requests_with_non_default_port(tmpdir: TempDir, port: u16) -> Result<( let body = reqwest::get(format!("http://localhost:{}", port).as_str())?.error_for_status()?; let parsed = Document::from_read(body)?; for &file in FILES { - assert!(parsed.find(Text).any(|x| x.text() == file)); + assert!(parsed.find(|x: &Node| x.text() == file).next().is_some()); + } + for &directory in DIRECTORIES { + assert!(parsed + .find(|x: &Node| x.text() == directory) + .next() + .is_some()); + let dir_body = reqwest::get(format!("http://localhost:{}/{}", port, directory).as_str())? + .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()); + } } child.kill()?; |