diff --git a/contrib/lib/src/templates/mod.rs b/contrib/lib/src/templates/mod.rs index 7a5df83b..4e879764 100644 --- a/contrib/lib/src/templates/mod.rs +++ b/contrib/lib/src/templates/mod.rs @@ -328,12 +328,11 @@ impl Template { /// use std::collections::HashMap; /// /// use rocket_contrib::templates::Template; - /// use rocket::local::asynchronous::Client; + /// use rocket::local::blocking::Client; /// /// fn main() { - /// # rocket::async_test(async { /// let rocket = rocket::ignite().attach(Template::fairing()); - /// let client = Client::new(rocket).await.expect("valid rocket"); + /// let client = Client::new(rocket).expect("valid rocket"); /// /// // Create a `context`. Here, just an empty `HashMap`. /// let mut context = HashMap::new(); @@ -341,7 +340,6 @@ impl Template { /// # context.insert("test", "test"); /// # #[allow(unused_variables)] /// let template = Template::show(client.cargo(), "index", context); - /// # }); /// } /// ``` #[inline] diff --git a/contrib/lib/tests/compress_responder.rs.disabled b/contrib/lib/tests/compress_responder.rs.disabled index 73384803..ee47f989 100644 --- a/contrib/lib/tests/compress_responder.rs.disabled +++ b/contrib/lib/tests/compress_responder.rs.disabled @@ -9,7 +9,7 @@ mod compress_responder_tests { use rocket::http::hyper::header::{ContentEncoding, Encoding}; use rocket::http::Status; use rocket::http::{ContentType, Header}; - use rocket::local::asynchronous::Client; + use rocket::local::blocking::Client; use rocket::response::{Content, Response}; use rocket_contrib::compression::Compress; diff --git a/contrib/lib/tests/compression_fairing.rs.disabled b/contrib/lib/tests/compression_fairing.rs.disabled index cabab825..91b280a1 100644 --- a/contrib/lib/tests/compression_fairing.rs.disabled +++ b/contrib/lib/tests/compression_fairing.rs.disabled @@ -10,7 +10,7 @@ mod compression_fairing_tests { use rocket::http::hyper::header::{ContentEncoding, Encoding}; use rocket::http::Status; use rocket::http::{ContentType, Header}; - use rocket::local::asynchronous::Client; + use rocket::local::blocking::Client; use rocket::response::{Content, Response}; use rocket_contrib::compression::Compression; diff --git a/contrib/lib/tests/helmet.rs b/contrib/lib/tests/helmet.rs index 192449a0..ca68a799 100644 --- a/contrib/lib/tests/helmet.rs +++ b/contrib/lib/tests/helmet.rs @@ -7,7 +7,7 @@ extern crate rocket; #[cfg(feature = "helmet")] mod helmet_tests { use rocket::http::{Status, uri::Uri}; - use rocket::local::asynchronous::{Client, LocalResponse}; + use rocket::local::blocking::{Client, LocalResponse}; use rocket_contrib::helmet::*; use time::Duration; @@ -34,15 +34,15 @@ mod helmet_tests { macro_rules! dispatch { ($helmet:expr, $closure:expr) => {{ let rocket = rocket::ignite().mount("/", routes![hello]).attach($helmet); - let client = Client::new(rocket).await.unwrap(); - let response = client.get("/").dispatch().await; + let client = Client::new(rocket).unwrap(); + let response = client.get("/").dispatch(); assert_eq!(response.status(), Status::Ok); $closure(response) }} } - #[rocket::async_test] - async fn default_headers_test() { + #[test] + fn default_headers_test() { dispatch!(SpaceHelmet::default(), |response: LocalResponse<'_>| { assert_header!(response, "X-XSS-Protection", "1"); assert_header!(response, "X-Frame-Options", "SAMEORIGIN"); @@ -50,8 +50,8 @@ mod helmet_tests { }) } - #[rocket::async_test] - async fn disable_headers_test() { + #[test] + fn disable_headers_test() { let helmet = SpaceHelmet::default().disable::(); dispatch!(helmet, |response: LocalResponse<'_>| { assert_header!(response, "X-Frame-Options", "SAMEORIGIN"); @@ -84,8 +84,8 @@ mod helmet_tests { }); } - #[rocket::async_test] - async fn additional_headers_test() { + #[test] + fn additional_headers_test() { let helmet = SpaceHelmet::default() .enable(Hsts::default()) .enable(ExpectCt::default()) @@ -108,8 +108,8 @@ mod helmet_tests { }) } - #[rocket::async_test] - async fn uri_test() { + #[test] + fn uri_test() { let allow_uri = Uri::parse("https://www.google.com").unwrap(); let report_uri = Uri::parse("https://www.google.com").unwrap(); let enforce_uri = Uri::parse("https://www.google.com").unwrap(); diff --git a/contrib/lib/tests/static_files.rs b/contrib/lib/tests/static_files.rs index e1685441..d12755a4 100644 --- a/contrib/lib/tests/static_files.rs +++ b/contrib/lib/tests/static_files.rs @@ -8,7 +8,7 @@ mod static_tests { use rocket::{self, Rocket, Route}; use rocket_contrib::serve::{StaticFiles, Options}; use rocket::http::Status; - use rocket::local::asynchronous::Client; + use rocket::local::blocking::Client; fn static_root() -> PathBuf { Path::new(env!("CARGO_MANIFEST_DIR")) @@ -45,9 +45,9 @@ mod static_tests { "inner/", ]; - async fn assert_file(client: &Client, prefix: &str, path: &str, exists: bool) { + fn assert_file(client: &Client, prefix: &str, path: &str, exists: bool) { let full_path = format!("/{}/{}", prefix, path); - let response = client.get(full_path).dispatch().await; + let response = client.get(full_path).dispatch(); if exists { assert_eq!(response.status(), Status::Ok); @@ -59,52 +59,52 @@ mod static_tests { let mut file = File::open(path).expect("open file"); let mut expected_contents = String::new(); file.read_to_string(&mut expected_contents).expect("read file"); - assert_eq!(response.into_string().await, Some(expected_contents)); + assert_eq!(response.into_string(), Some(expected_contents)); } else { assert_eq!(response.status(), Status::NotFound); } } - async fn assert_all(client: &Client, prefix: &str, paths: &[&str], exist: bool) { + fn assert_all(client: &Client, prefix: &str, paths: &[&str], exist: bool) { for path in paths.iter() { - assert_file(client, prefix, path, exist).await; + assert_file(client, prefix, path, exist); } } - #[rocket::async_test] - async fn test_static_no_index() { - let client = Client::new(rocket()).await.expect("valid rocket"); - assert_all(&client, "no_index", REGULAR_FILES, true).await; - assert_all(&client, "no_index", HIDDEN_FILES, false).await; - assert_all(&client, "no_index", INDEXED_DIRECTORIES, false).await; + #[test] + fn test_static_no_index() { + let client = Client::new(rocket()).expect("valid rocket"); + assert_all(&client, "no_index", REGULAR_FILES, true); + assert_all(&client, "no_index", HIDDEN_FILES, false); + assert_all(&client, "no_index", INDEXED_DIRECTORIES, false); } - #[rocket::async_test] - async fn test_static_hidden() { - let client = Client::new(rocket()).await.expect("valid rocket"); - assert_all(&client, "dots", REGULAR_FILES, true).await; - assert_all(&client, "dots", HIDDEN_FILES, true).await; - assert_all(&client, "dots", INDEXED_DIRECTORIES, false).await; + #[test] + fn test_static_hidden() { + let client = Client::new(rocket()).expect("valid rocket"); + assert_all(&client, "dots", REGULAR_FILES, true); + assert_all(&client, "dots", HIDDEN_FILES, true); + assert_all(&client, "dots", INDEXED_DIRECTORIES, false); } - #[rocket::async_test] - async fn test_static_index() { - let client = Client::new(rocket()).await.expect("valid rocket"); - assert_all(&client, "index", REGULAR_FILES, true).await; - assert_all(&client, "index", HIDDEN_FILES, false).await; - assert_all(&client, "index", INDEXED_DIRECTORIES, true).await; + #[test] + fn test_static_index() { + let client = Client::new(rocket()).expect("valid rocket"); + assert_all(&client, "index", REGULAR_FILES, true); + assert_all(&client, "index", HIDDEN_FILES, false); + assert_all(&client, "index", INDEXED_DIRECTORIES, true); - assert_all(&client, "default", REGULAR_FILES, true).await; - assert_all(&client, "default", HIDDEN_FILES, false).await; - assert_all(&client, "default", INDEXED_DIRECTORIES, true).await; + assert_all(&client, "default", REGULAR_FILES, true); + assert_all(&client, "default", HIDDEN_FILES, false); + assert_all(&client, "default", INDEXED_DIRECTORIES, true); } - #[rocket::async_test] - async fn test_static_all() { - let client = Client::new(rocket()).await.expect("valid rocket"); - assert_all(&client, "both", REGULAR_FILES, true).await; - assert_all(&client, "both", HIDDEN_FILES, true).await; - assert_all(&client, "both", INDEXED_DIRECTORIES, true).await; + #[test] + fn test_static_all() { + let client = Client::new(rocket()).expect("valid rocket"); + assert_all(&client, "both", REGULAR_FILES, true); + assert_all(&client, "both", HIDDEN_FILES, true); + assert_all(&client, "both", INDEXED_DIRECTORIES, true); } #[test] @@ -121,8 +121,8 @@ mod static_tests { } } - #[rocket::async_test] - async fn test_forwarding() { + #[test] + fn test_forwarding() { use rocket::http::RawStr; use rocket::{get, routes}; @@ -133,19 +133,19 @@ mod static_tests { fn catch_two(a: &RawStr, b: &RawStr) -> String { format!("{}/{}", a, b) } let rocket = rocket().mount("/default", routes![catch_one, catch_two]); - let client = Client::new(rocket).await.expect("valid rocket"); + let client = Client::new(rocket).expect("valid rocket"); - let response = client.get("/default/ireallydontexist").dispatch().await; + let response = client.get("/default/ireallydontexist").dispatch(); assert_eq!(response.status(), Status::Ok); - assert_eq!(response.into_string().await.unwrap(), "ireallydontexist"); + assert_eq!(response.into_string().unwrap(), "ireallydontexist"); - let response = client.get("/default/idont/exist").dispatch().await; + let response = client.get("/default/idont/exist").dispatch(); assert_eq!(response.status(), Status::Ok); - assert_eq!(response.into_string().await.unwrap(), "idont/exist"); + assert_eq!(response.into_string().unwrap(), "idont/exist"); - assert_all(&client, "both", REGULAR_FILES, true).await; - assert_all(&client, "both", HIDDEN_FILES, true).await; - assert_all(&client, "both", INDEXED_DIRECTORIES, true).await; + assert_all(&client, "both", REGULAR_FILES, true); + assert_all(&client, "both", HIDDEN_FILES, true); + assert_all(&client, "both", INDEXED_DIRECTORIES, true); } #[test] diff --git a/contrib/lib/tests/templates.rs b/contrib/lib/tests/templates.rs index 08c568b2..b8e7900b 100644 --- a/contrib/lib/tests/templates.rs +++ b/contrib/lib/tests/templates.rs @@ -42,7 +42,7 @@ mod templates_tests { use super::*; use std::collections::HashMap; use rocket::http::Status; - use rocket::local::asynchronous::Client; + use rocket::local::blocking::Client; const UNESCAPED_EXPECTED: &'static str = "\nh_start\ntitle: _test_\nh_end\n\n\n