diff --git a/CHANGES.md b/CHANGES.md index 0c27aaa1c..6494ba4f6 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -9,14 +9,20 @@ * Align `DefaultHeader` method terminology, deprecating previous methods. [#2510] * Response service types in `ErrorHandlers` middleware now use `ServiceResponse>` to allow changing the body type. [#2515] * Both variants in `ErrorHandlerResponse` now use `ServiceResponse>`. [#2515] +* Rename `test::{default_service => simple_service}`. Old name is deprecated. [#2518] +* Rename `test::{read_response_json => call_and_read_body_json}`. Old name is deprecated. [#2518] +* Rename `test::{read_response => call_and_read_body}`. Old name is deprecated. [#2518] +* Relax body type and error bounds on test utilities. ### Removed * Top-level `EitherExtractError` export. [#2510] * Conversion implementations for `either` crate. [#2516] +* `test::load_stream` and `test::load_body`; replace usage with `body::to_bytes`. [#2518] [#2510]: https://github.com/actix/actix-web/pull/2510 [#2515]: https://github.com/actix/actix-web/pull/2515 [#2516]: https://github.com/actix/actix-web/pull/2516 +[#2518]: https://github.com/actix/actix-web/pull/2518 ## 4.0.0-beta.14 - 2021-12-11 diff --git a/actix-test/CHANGES.md b/actix-test/CHANGES.md index ec7d3e8d1..b7107b44f 100644 --- a/actix-test/CHANGES.md +++ b/actix-test/CHANGES.md @@ -1,6 +1,10 @@ # Changes ## Unreleased - 2021-xx-xx +* Re-export `actix_http::body::to_bytes`. [#2518] +* Update `actix_web::test` re-exports. [#2518] + +[#2518]: https://github.com/actix/actix-web/pull/2518 ## 0.1.0-beta.8 - 2021-12-11 diff --git a/actix-test/src/lib.rs b/actix-test/src/lib.rs index 5f247b11a..3808ba69a 100644 --- a/actix-test/src/lib.rs +++ b/actix-test/src/lib.rs @@ -42,8 +42,8 @@ use actix_http::{header::HeaderMap, ws, HttpService, Method, Request, Response}; pub use actix_http_test::unused_addr; use actix_service::{map_config, IntoServiceFactory, ServiceFactory, ServiceFactoryExt as _}; pub use actix_web::test::{ - call_service, init_service, ok_service, read_body, read_body_json, read_response, - read_response_json, simple_service, TestRequest, + call_and_read_body, call_and_read_body_json, call_service, init_service, ok_service, + read_body, read_body_json, simple_service, TestRequest, }; use actix_web::{ body::MessageBody, diff --git a/src/test/test_utils.rs b/src/test/test_utils.rs index e7f488edd..02d4c9bf3 100644 --- a/src/test/test_utils.rs +++ b/src/test/test_utils.rs @@ -344,7 +344,7 @@ mod tests { .insert_header((header::CONTENT_TYPE, "application/json")) .to_request(); - let result = read_response(&app, put_req).await; + let result = call_and_read_body(&app, put_req).await; assert_eq!(result, Bytes::from_static(b"put!")); let patch_req = TestRequest::patch() @@ -352,11 +352,11 @@ mod tests { .insert_header((header::CONTENT_TYPE, "application/json")) .to_request(); - let result = read_response(&app, patch_req).await; + let result = call_and_read_body(&app, patch_req).await; assert_eq!(result, Bytes::from_static(b"patch!")); let delete_req = TestRequest::delete().uri("/index.html").to_request(); - let result = read_response(&app, delete_req).await; + let result = call_and_read_body(&app, delete_req).await; assert_eq!(result, Bytes::from_static(b"delete!")); } @@ -381,7 +381,7 @@ mod tests { .set_payload(payload) .to_request(); - let result: Person = read_response_json(&app, req).await; + let result: Person = call_and_read_body_json(&app, req).await; assert_eq!(&result.id, "12345"); } @@ -424,7 +424,7 @@ mod tests { assert_eq!(req.content_type(), "application/x-www-form-urlencoded"); - let result: Person = read_response_json(&app, req).await; + let result: Person = call_and_read_body_json(&app, req).await; assert_eq!(&result.id, "12345"); assert_eq!(&result.name, "User name"); } @@ -444,7 +444,7 @@ mod tests { .insert_header((header::CONTENT_TYPE, "application/json")) .to_request(); - let result = read_response(&app, req).await; + let result = call_and_read_body(&app, req).await; assert_eq!(result, Bytes::from_static(b"welcome!")); } @@ -467,7 +467,7 @@ mod tests { assert_eq!(req.content_type(), "application/json"); - let result: Person = read_response_json(&app, req).await; + let result: Person = call_and_read_body_json(&app, req).await; assert_eq!(&result.id, "12345"); assert_eq!(&result.name, "User name"); }