Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
robjtede committed Jan 18, 2022
1 parent 7f21c71 commit d54acbe
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/extract.rs
Original file line number Diff line number Diff line change
@@ -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;
14 changes: 7 additions & 7 deletions src/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
///
Expand All @@ -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)]
Expand All @@ -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<Info, DEFAULT_LIMIT>) -> String {
/// async fn index(info: Json<Info, DEFAULT_JSON_LIMIT>) -> String {
/// format!("Welcome {}!", info.username)
/// }
///
Expand Down Expand Up @@ -258,7 +258,7 @@ mod tests {
.set_payload(Bytes::from_static(b"{\"name\": \"test\"}"))
.to_http_parts();

let s = Json::<MyObject, DEFAULT_LIMIT>::from_request(&req, &mut pl)
let s = Json::<MyObject, DEFAULT_JSON_LIMIT>::from_request(&req, &mut pl)
.await
.unwrap();
assert_eq!(s.name, "test");
Expand Down Expand Up @@ -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::<MyObject, DEFAULT_LIMIT>::new(&req, &mut pl).await;
let json = JsonBody::<MyObject, DEFAULT_JSON_LIMIT>::new(&req, &mut pl).await;
assert!(json_eq(json.unwrap_err(), JsonPayloadError::ContentType));

let (req, mut pl) = TestRequest::default()
Expand All @@ -315,7 +315,7 @@ mod tests {
header::HeaderValue::from_static("application/text"),
))
.to_http_parts();
let json = JsonBody::<MyObject, DEFAULT_LIMIT>::new(&req, &mut pl).await;
let json = JsonBody::<MyObject, DEFAULT_JSON_LIMIT>::new(&req, &mut pl).await;
assert!(json_eq(json.unwrap_err(), JsonPayloadError::ContentType));

let (req, mut pl) = TestRequest::default()
Expand Down Expand Up @@ -356,7 +356,7 @@ mod tests {
.set_payload(Bytes::from_static(b"{\"name\": \"test\"}"))
.to_http_parts();

let json = JsonBody::<MyObject, DEFAULT_LIMIT>::new(&req, &mut pl).await;
let json = JsonBody::<MyObject, DEFAULT_JSON_LIMIT>::new(&req, &mut pl).await;
assert_eq!(
json.ok().unwrap(),
MyObject {
Expand Down
8 changes: 4 additions & 4 deletions src/redirect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand Down Expand Up @@ -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");
/// ```
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit d54acbe

Please sign in to comment.