From d54acbecc395e0991aa1bdaffc9f2bc55c46a4f9 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Tue, 18 Jan 2022 02:12:40 +0000 Subject: [PATCH] fix tests --- src/extract.rs | 2 +- src/json.rs | 14 +++++++------- src/redirect.rs | 8 ++++---- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/extract.rs b/src/extract.rs index 60782e1a..ec423b01 100644 --- a/src/extract.rs +++ b/src/extract.rs @@ -1,4 +1,4 @@ //! Experimental extractors. -pub use crate::json::Json; +pub use crate::json::{Json, DEFAULT_JSON_LIMIT}; pub use crate::lazy_data::LazyData; diff --git a/src/json.rs b/src/json.rs index 09c4c526..c54e6f82 100644 --- a/src/json.rs +++ b/src/json.rs @@ -18,7 +18,7 @@ use actix_web::{ HttpRequest, }; -pub const DEFAULT_LIMIT: usize = 2_097_152; // 2MiB +pub const DEFAULT_JSON_LIMIT: usize = 2_097_152; // 2MiB /// JSON extractor with const-generic payload size limit. /// @@ -36,7 +36,7 @@ pub const DEFAULT_LIMIT: usize = 2_097_152; // 2MiB /// /// ``` /// use actix_web::{post, App}; -/// use actix_web_lab::json::{DEFAULT_LIMIT, Json}; +/// use actix_web_lab::extract::{DEFAULT_JSON_LIMIT, Json}; /// use serde::Deserialize; /// /// #[derive(Deserialize)] @@ -46,7 +46,7 @@ pub const DEFAULT_LIMIT: usize = 2_097_152; // 2MiB /// /// /// Deserialize `Info` from request's body. /// #[post("/")] -/// async fn index(info: Json) -> String { +/// async fn index(info: Json) -> String { /// format!("Welcome {}!", info.username) /// } /// @@ -258,7 +258,7 @@ mod tests { .set_payload(Bytes::from_static(b"{\"name\": \"test\"}")) .to_http_parts(); - let s = Json::::from_request(&req, &mut pl) + let s = Json::::from_request(&req, &mut pl) .await .unwrap(); assert_eq!(s.name, "test"); @@ -306,7 +306,7 @@ mod tests { #[actix_web::test] async fn test_json_body() { let (req, mut pl) = TestRequest::default().to_http_parts(); - let json = JsonBody::::new(&req, &mut pl).await; + let json = JsonBody::::new(&req, &mut pl).await; assert!(json_eq(json.unwrap_err(), JsonPayloadError::ContentType)); let (req, mut pl) = TestRequest::default() @@ -315,7 +315,7 @@ mod tests { header::HeaderValue::from_static("application/text"), )) .to_http_parts(); - let json = JsonBody::::new(&req, &mut pl).await; + let json = JsonBody::::new(&req, &mut pl).await; assert!(json_eq(json.unwrap_err(), JsonPayloadError::ContentType)); let (req, mut pl) = TestRequest::default() @@ -356,7 +356,7 @@ mod tests { .set_payload(Bytes::from_static(b"{\"name\": \"test\"}")) .to_http_parts(); - let json = JsonBody::::new(&req, &mut pl).await; + let json = JsonBody::::new(&req, &mut pl).await; assert_eq!( json.ok().unwrap(), MyObject { diff --git a/src/redirect.rs b/src/redirect.rs index af0669df..11bf8099 100644 --- a/src/redirect.rs +++ b/src/redirect.rs @@ -19,11 +19,11 @@ use actix_web::{ /// # Examples /// ``` /// use actix_web::{web, App}; -/// use actix_web_lab::{web as web_lab, Redirect}; +/// use actix_web_lab::web as web_lab; /// /// App::new() /// // redirect "/duck" to DuckDuckGo -/// .service(Redirect::new("/duck", "https://duckduckgo.com/")) +/// .service(web_lab::Redirect::new("/duck", "https://duckduckgo.com/")) /// .service( /// // redirect "/api/old" to "/api/new" using `web::redirect` helper /// web::scope("/api").service(web_lab::redirect("/old", "/new")) @@ -53,7 +53,7 @@ impl Redirect { /// /// # Examples /// ``` - /// # use actix_web_lab::Redirect; + /// # use actix_web_lab::web::Redirect; /// // redirects "/oh/hi/mark" to "/oh/bye/mark" /// Redirect::new("/oh/hi/mark", "../../bye/mark"); /// ``` @@ -93,7 +93,7 @@ impl Redirect { /// /// ``` /// # use actix_web::http::StatusCode; - /// # use actix_web_lab::Redirect; + /// # use actix_web_lab::web::Redirect; /// // redirects would use "301 Moved Permanently" status code /// Redirect::new("/old", "/new") /// .using_status_code(StatusCode::MOVED_PERMANENTLY);