diff options
author | Sven-Hendrik Haase <svenstaro@gmail.com> | 2019-05-01 05:56:35 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-01 05:56:35 +0000 |
commit | f099134d2b86924fad0ddc615e5fecfb716c7ee0 (patch) | |
tree | d1142b0fd13b2ed92f1216b0672df8befc81d928 /tests/serve_request.rs | |
parent | Merge pull request #96 from svenstaro/dependabot/cargo/reqwest-0.9.16 (diff) | |
parent | Allow dead code to fix false negative warnings (diff) | |
download | miniserve-f099134d2b86924fad0ddc615e5fecfb716c7ee0.tar.gz miniserve-f099134d2b86924fad0ddc615e5fecfb716c7ee0.zip |
Merge pull request #91 from KSXGitHub/split-integration-test
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..31b9b75 --- /dev/null +++ b/tests/serve_request.rs @@ -0,0 +1,44 @@ +mod fixtures; +use fixtures::*; + +#[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(()) +} |