From cf0ce2ce2b70a1b19b3554318fc69a4ecf4e083a Mon Sep 17 00:00:00 2001 From: Sven-Hendrik Haase Date: Wed, 11 Mar 2020 15:18:15 +0100 Subject: Bump reqwests to v0.10 --- tests/upload_files.rs | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'tests/upload_files.rs') 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)); -- cgit v1.2.3