pub struct TestRequest { /* private fields */ }
Expand description

A simpler version of Request that is useful for testing. No data actually goes anywhere.

By default, TestRequest pretends to be an insecure GET request for the server root (/) with no headers. To create a TestRequest with different parameters, use the builder pattern:

let request = TestRequest::new()
    .with_method(Method::Post)
    .with_path("/api/widgets")
    .with_body("42");

Then, convert the TestRequest into a real Request and pass it to the server under test:

let response = server.handle_request(request.into());
assert_eq!(response.status_code(), StatusCode(200));

Implementations

Trait Implementations

Returns the “default value” for a type. Read more

Performs the conversion.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.