mirror of
https://github.com/fafhrd91/actix-web
synced 2024-11-27 17:52:56 +01:00
add test for form extractor
This commit is contained in:
parent
45b408526c
commit
0a080d9fb4
@ -6,6 +6,8 @@
|
|||||||
|
|
||||||
* Add `ClientRequestBuilder::form()` for sending `application/x-www-form-urlencoded` requests.
|
* Add `ClientRequestBuilder::form()` for sending `application/x-www-form-urlencoded` requests.
|
||||||
|
|
||||||
|
* Add method to configure custom error handler to Form extractor.
|
||||||
|
|
||||||
* Add methods to `HttpResponse` to retrieve, add, and delete cookies
|
* Add methods to `HttpResponse` to retrieve, add, and delete cookies
|
||||||
|
|
||||||
* Add `.set_content_type()` and `.set_content_disposition()` methods
|
* Add `.set_content_type()` and `.set_content_disposition()` methods
|
||||||
|
@ -125,6 +125,30 @@ fn test_form_extractor() {
|
|||||||
assert_eq!(bytes, Bytes::from_static(b"test"));
|
assert_eq!(bytes, Bytes::from_static(b"test"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_form_extractor2() {
|
||||||
|
let mut srv = test::TestServer::new(|app| {
|
||||||
|
app.resource("/{username}/index.html", |r| {
|
||||||
|
r.route().with(|form: Form<FormData>| {
|
||||||
|
format!("{}", form.username)
|
||||||
|
}).error_handler(|err, res| {
|
||||||
|
error::InternalError::from_response(
|
||||||
|
err, HttpResponse::Conflict().finish()).into()
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// client request
|
||||||
|
let request = srv
|
||||||
|
.post()
|
||||||
|
.uri(srv.url("/test1/index.html"))
|
||||||
|
.header("content-type", "application/x-www-form-urlencoded")
|
||||||
|
.body("918237129hdk:D:D:D:D:D:DjASHDKJhaswkjeq")
|
||||||
|
.unwrap();
|
||||||
|
let response = srv.execute(request.send()).unwrap();
|
||||||
|
assert!(response.status().is_client_error());
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_path_and_query_extractor() {
|
fn test_path_and_query_extractor() {
|
||||||
let mut srv = test::TestServer::new(|app| {
|
let mut srv = test::TestServer::new(|app| {
|
||||||
|
Loading…
Reference in New Issue
Block a user