Crate yup_hyper_mock
source ·Expand description
Contains various utility types and macros useful for testing hyper clients.
Macros
The mock_connector!
and mock_connector_in_order!
macros can be used to
feed a client with preset data. That way you can control exactly what it will
see, confining the test-case to its own sandbox that way.
All types they define are public to allow them to be used in other unit-tests. Please note that integration tests cannot share their mock types anyway, as each integration test goes into its own binary.
Usage
Set it up for use in tests in Cargo.toml
[dev-dependencies]
yup-hyper-mock = "*"
log = "*" # log macros are used within yup-hyper-mock
Link it into your src/(lib.rs|main.rs)
#[cfg(test)] #[macro_use]
extern crate "yup-hyper-mock" as hyper_mock
Macros
- This macro maps host URLs to a respective reply, which is given in plain-text. It ignores everything that is written to it.
- This macro yields all given server replies in the order they are given. The destination host URL doesn’t matter at all.
Structs
- A
Connect
which provides a single reply stream per host. - A connector which requires you to implement the
Default
trait, allowing you to determine the data it should be initialized with