Skip to content

Commit

Permalink
remove -http TestRequest doc test
Browse files Browse the repository at this point in the history
  • Loading branch information
robjtede committed Mar 28, 2022
1 parent 40048a5 commit 2fed978
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 26 deletions.
24 changes: 1 addition & 23 deletions actix-http/src/test.rs
Expand Up @@ -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 {
Expand Down
7 changes: 4 additions & 3 deletions actix-web/src/test/test_request.rs
Expand Up @@ -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 {
Expand All @@ -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();
Expand Down

0 comments on commit 2fed978

Please sign in to comment.