Skip to main content

TestRequestBuilder

Struct TestRequestBuilder 

Source
pub struct TestRequestBuilder<'a, T>
where T: TestClient + ?Sized,
{ /* private fields */ }
Expand description

Fluent request builder for test clients

Implementations§

Source§

impl<'a, T> TestRequestBuilder<'a, T>
where T: TestClient + ?Sized,

Source

pub const fn new( client: &'a T, method: HttpMethod, path: String, ) -> TestRequestBuilder<'a, T>

Create a new request builder

Source

pub fn header<K, V>(self, key: K, value: V) -> TestRequestBuilder<'a, T>
where K: Into<String>, V: Into<String>,

Add a header to the request

Source

pub fn headers<K, V>( self, headers: impl IntoIterator<Item = (K, V)>, ) -> TestRequestBuilder<'a, T>
where K: Into<String>, V: Into<String>,

Add multiple headers to the request

Source

pub fn content_type(self, content_type: &str) -> TestRequestBuilder<'a, T>

Set the Content-Type header

Source

pub fn authorization(self, auth: &str) -> TestRequestBuilder<'a, T>

Set the Authorization header

Source

pub fn bearer_token(self, token: &str) -> TestRequestBuilder<'a, T>

Set the Authorization header with Bearer token

Source

pub fn user_agent(self, user_agent: &str) -> TestRequestBuilder<'a, T>

Set the User-Agent header

Source

pub fn body_bytes(self, body: Vec<u8>) -> TestRequestBuilder<'a, T>

Set a raw byte body

Source

pub fn form<K, V>( self, data: impl IntoIterator<Item = (K, V)>, ) -> TestRequestBuilder<'a, T>
where K: Into<String>, V: Into<String>,

Set a form body from key-value pairs

Source

pub fn text(self, text: String) -> TestRequestBuilder<'a, T>

Set a plain text body

Source

pub fn send(self) -> Result<TestResponse, <T as TestClient>::Error>

Execute the request and return the response

§Errors
  • Returns error if the request execution fails
§Panics
  • Panics if request body serialization fails
Source§

impl<T> TestRequestBuilder<'_, T>
where T: TestClient + ?Sized,

Convenience methods for common request patterns

Source

pub fn query<K, V>( self, params: impl IntoIterator<Item = (K, V)>, ) -> TestRequestBuilder<'_, T>
where K: Into<String>, V: Into<String>,

Create a GET request with query parameters

Source

pub fn form_post<K, V>( self, data: impl IntoIterator<Item = (K, V)>, ) -> TestRequestBuilder<'_, T>
where K: Into<String>, V: Into<String>,

Create a form POST request

Source

pub fn basic_auth( self, username: &str, password: Option<&str>, ) -> TestRequestBuilder<'_, T>

Create a request with basic authentication

Auto Trait Implementations§

§

impl<'a, T> Freeze for TestRequestBuilder<'a, T>
where T: ?Sized,

§

impl<'a, T> RefUnwindSafe for TestRequestBuilder<'a, T>
where T: RefUnwindSafe + ?Sized,

§

impl<'a, T> Send for TestRequestBuilder<'a, T>
where T: Sync + ?Sized,

§

impl<'a, T> Sync for TestRequestBuilder<'a, T>
where T: Sync + ?Sized,

§

impl<'a, T> Unpin for TestRequestBuilder<'a, T>
where T: ?Sized,

§

impl<'a, T> UnsafeUnpin for TestRequestBuilder<'a, T>
where T: ?Sized,

§

impl<'a, T> UnwindSafe for TestRequestBuilder<'a, T>
where T: RefUnwindSafe + ?Sized,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FutureExt for T

Source§

fn with_context(self, otel_cx: Context) -> WithContext<Self>

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
Source§

fn with_current_context(self) -> WithContext<Self>

Attaches the current Context to this type, returning a WithContext wrapper. Read more
Source§

impl<T> HandlerSend for T

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<L> LayerExt<L> for L

Source§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in Layered.
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T, U> TryIntoDb<U> for T
where T: Send, U: TryFromDb<T>,

Source§

type Error = <U as TryFromDb<T>>::Error

The error type returned when conversion fails
Source§

fn try_into_db<'async_trait>( self, db: Arc<Box<dyn Database>>, ) -> Pin<Box<dyn Future<Output = Result<U, <U as TryFromDb<T>>::Error>> + Send + 'async_trait>>
where T: 'async_trait,

Attempts to convert from Self to T with database context Read more
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more