1
0
Fork 0
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:
Rob Ede 2022-03-28 22:44:32 +01:00
parent 40048a5811
commit 2fed978597
No known key found for this signature in database
GPG key ID: 97C636207D3EF933
2 changed files with 5 additions and 26 deletions

View file

@ -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 {

View file

@ -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();