diff options
author | khai96_ <hvksmr1996@gmail.com> | 2019-04-28 18:07:02 +0000 |
---|---|---|
committer | khai96_ <hvksmr1996@gmail.com> | 2019-04-28 18:07:02 +0000 |
commit | a07c1bdf4da77c8227c110e750fce7169618d75e (patch) | |
tree | e93702a231f343076cdc74afda1d954c257175c2 /tests/serve_request.rs | |
parent | Merge pull request #86 from KSXGitHub/test-hash-auth (diff) | |
download | miniserve-a07c1bdf4da77c8227c110e750fce7169618d75e.tar.gz miniserve-a07c1bdf4da77c8227c110e750fce7169618d75e.zip |
Split integration test into multiple files
Diffstat (limited to 'tests/serve_request.rs')
-rw-r--r-- | tests/serve_request.rs | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/serve_request.rs b/tests/serve_request.rs new file mode 100644 index 0000000..10b2bfc --- /dev/null +++ b/tests/serve_request.rs @@ -0,0 +1,44 @@ +mod helpers; +use helpers::*; + +#[rstest] +fn serves_requests_with_no_options(tmpdir: TempDir) -> Result<(), Error> { + let mut child = Command::cargo_bin("miniserve")? + .arg(tmpdir.path()) + .stdout(Stdio::null()) + .spawn()?; + + sleep(Duration::from_secs(1)); + + 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)); + } + + child.kill()?; + + Ok(()) +} + +#[rstest] +fn serves_requests_with_non_default_port(tmpdir: TempDir, port: u16) -> Result<(), Error> { + let mut child = Command::cargo_bin("miniserve")? + .arg(tmpdir.path()) + .arg("-p") + .arg(port.to_string()) + .stdout(Stdio::null()) + .spawn()?; + + sleep(Duration::from_secs(1)); + + 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)); + } + + child.kill()?; + + Ok(()) +} |