aboutsummaryrefslogtreecommitdiffstats
path: root/tests/upload_files.rs
diff options
context:
space:
mode:
authorSven-Hendrik Haase <svenstaro@gmail.com>2020-03-11 14:18:15 +0000
committerSven-Hendrik Haase <svenstaro@gmail.com>2020-03-11 14:18:15 +0000
commitcf0ce2ce2b70a1b19b3554318fc69a4ecf4e083a (patch)
tree16576efac3d8b4f4e004d5c4fe6ae85fdcbbe28c /tests/upload_files.rs
parentMerge pull request #272 from svenstaro/dependabot/cargo/base64-0.12.0 (diff)
downloadminiserve-cf0ce2ce2b70a1b19b3554318fc69a4ecf4e083a.tar.gz
miniserve-cf0ce2ce2b70a1b19b3554318fc69a4ecf4e083a.zip
Bump reqwests to v0.10
Diffstat (limited to '')
-rw-r--r--tests/upload_files.rs23
1 files changed, 13 insertions, 10 deletions
diff --git a/tests/upload_files.rs b/tests/upload_files.rs
index 53833a6..58707c5 100644
--- a/tests/upload_files.rs
+++ b/tests/upload_files.rs
@@ -3,7 +3,7 @@ mod fixtures;
use assert_cmd::prelude::*;
use assert_fs::fixture::TempDir;
use fixtures::{port, tmpdir, Error};
-use reqwest::multipart;
+use reqwest::blocking::{multipart, Client};
use rstest::rstest;
use select::document::Document;
use select::predicate::{Attr, Text};
@@ -26,7 +26,8 @@ fn uploading_files_works(tmpdir: TempDir, port: u16) -> Result<(), Error> {
sleep(Duration::from_secs(1));
// Before uploading, check whether the uploaded file does not yet exist.
- let body = reqwest::get(format!("http://localhost:{}", port).as_str())?.error_for_status()?;
+ let body = reqwest::blocking::get(format!("http://localhost:{}", port).as_str())?
+ .error_for_status()?;
let parsed = Document::from_read(body)?;
assert!(parsed.find(Text).all(|x| x.text() != test_file_name));
@@ -43,7 +44,7 @@ fn uploading_files_works(tmpdir: TempDir, port: u16) -> Result<(), Error> {
.mime_str("text/plain")?;
let form = form.part("file_to_upload", part);
- let client = reqwest::Client::new();
+ let client = Client::new();
client
.post(format!("http://localhost:{}{}", port, upload_action).as_str())
.multipart(form)
@@ -51,7 +52,7 @@ fn uploading_files_works(tmpdir: TempDir, port: u16) -> Result<(), Error> {
.error_for_status()?;
// After uploading, check whether the uploaded file is now getting listed.
- let body = reqwest::get(format!("http://localhost:{}", port).as_str())?;
+ let body = reqwest::blocking::get(format!("http://localhost:{}", port).as_str())?;
let parsed = Document::from_read(body)?;
assert!(parsed.find(Text).any(|x| x.text() == test_file_name));
@@ -74,13 +75,14 @@ fn uploading_files_is_prevented(tmpdir: TempDir, port: u16) -> Result<(), Error>
sleep(Duration::from_secs(1));
// Before uploading, check whether the uploaded file does not yet exist.
- let body = reqwest::get(format!("http://localhost:{}", port).as_str())?.error_for_status()?;
+ let body = reqwest::blocking::get(format!("http://localhost:{}", port).as_str())?
+ .error_for_status()?;
let parsed = Document::from_read(body)?;
assert!(parsed.find(Text).all(|x| x.text() != test_file_name));
-
+
// Ensure the file upload form is not present
assert!(parsed.find(Attr("id", "file_submit")).next().is_none());
-
+
// Then try to upload anyway
let form = multipart::Form::new();
let part = multipart::Part::text("this should not be uploaded")
@@ -88,16 +90,17 @@ fn uploading_files_is_prevented(tmpdir: TempDir, port: u16) -> Result<(), Error>
.mime_str("text/plain")?;
let form = form.part("file_to_upload", part);
- let client = reqwest::Client::new();
+ let client = Client::new();
// Ensure uploading fails and returns an error
assert!(client
.post(format!("http://localhost:{}{}", port, "/upload?path=/").as_str())
.multipart(form)
.send()?
- .error_for_status().is_err());
+ .error_for_status()
+ .is_err());
// After uploading, check whether the uploaded file is now getting listed.
- let body = reqwest::get(format!("http://localhost:{}", port).as_str())?;
+ let body = reqwest::blocking::get(format!("http://localhost:{}", port).as_str())?;
let parsed = Document::from_read(body)?;
assert!(!parsed.find(Text).any(|x| x.text() == test_file_name));