mirror of
https://github.com/actix/actix-web.git
synced 2024-12-26 18:10:37 +00:00
remove -http TestRequest doc test
This commit is contained in:
parent
40048a5811
commit
2fed978597
2 changed files with 5 additions and 26 deletions
|
@ -19,29 +19,7 @@ use crate::{
|
|||
Request,
|
||||
};
|
||||
|
||||
/// Test `Request` builder
|
||||
///
|
||||
/// ```ignore
|
||||
/// # use http::{header, StatusCode};
|
||||
/// # use actix_web::*;
|
||||
/// use actix_web::test::TestRequest;
|
||||
///
|
||||
/// fn index(req: &HttpRequest) -> Response {
|
||||
/// if let Some(hdr) = req.headers().get(header::CONTENT_TYPE) {
|
||||
/// Response::Ok().into()
|
||||
/// } else {
|
||||
/// Response::BadRequest().into()
|
||||
/// }
|
||||
/// }
|
||||
///
|
||||
/// let resp = TestRequest::default().insert_header("content-type", "text/plain")
|
||||
/// .run(&index)
|
||||
/// .unwrap();
|
||||
/// assert_eq!(resp.status(), StatusCode::OK);
|
||||
///
|
||||
/// let resp = TestRequest::default().run(&index).unwrap();
|
||||
/// assert_eq!(resp.status(), StatusCode::BAD_REQUEST);
|
||||
/// ```
|
||||
/// Test `Request` builder.
|
||||
pub struct TestRequest(Option<Inner>);
|
||||
|
||||
struct Inner {
|
||||
|
|
|
@ -33,7 +33,7 @@ use crate::cookie::{Cookie, CookieJar};
|
|||
/// use actix_web::{test, HttpRequest, HttpResponse, HttpMessage};
|
||||
/// use actix_web::http::{header, StatusCode};
|
||||
///
|
||||
/// async fn index(req: HttpRequest) -> HttpResponse {
|
||||
/// async fn handler(req: HttpRequest) -> HttpResponse {
|
||||
/// if let Some(hdr) = req.headers().get(header::CONTENT_TYPE) {
|
||||
/// HttpResponse::Ok().into()
|
||||
/// } else {
|
||||
|
@ -45,10 +45,11 @@ use crate::cookie::{Cookie, CookieJar};
|
|||
/// # // force rustdoc to display the correct thing and also compile check the test
|
||||
/// # async fn _test() {}
|
||||
/// async fn test_index() {
|
||||
/// let req = test::TestRequest::default().insert_header(header::ContentType::plaintext())
|
||||
/// let req = test::TestRequest::default()
|
||||
/// .insert_header(header::ContentType::plaintext())
|
||||
/// .to_http_request();
|
||||
///
|
||||
/// let resp = index(req).await;
|
||||
/// let resp = handler(req).await;
|
||||
/// assert_eq!(resp.status(), StatusCode::OK);
|
||||
///
|
||||
/// let req = test::TestRequest::default().to_http_request();
|
||||
|
|
Loading…
Reference in a new issue