wisp/testing
Constants
pub const default_secret_key_base: String = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
The default secret key base used for test requests. This should never be used outside of tests.
Functions
pub fn bit_string_body(response: Response(Body)) -> BitString
Read the body of a response as a bit string
Panics
This function will panic if the response body is a file and the file cannot be read.
pub fn connect(path: String, headers: List(#(String, String))) -> Request(
Connection,
)
Create a test HTTP request that can be used to test your request handler.
pub fn delete(path: String, headers: List(#(String, String)), body: String) -> Request(
Connection,
)
Create a test HTTP request that can be used to test your request handler.
pub fn get(path: String, headers: List(#(String, String))) -> Request(
Connection,
)
Create a test HTTP request that can be used to test your request handler.
pub fn head(path: String, headers: List(#(String, String))) -> Request(
Connection,
)
Create a test HTTP request that can be used to test your request handler.
pub fn options(path: String, headers: List(#(String, String))) -> Request(
Connection,
)
Create a test HTTP request that can be used to test your request handler.
pub fn patch(path: String, headers: List(#(String, String)), body: String) -> Request(
Connection,
)
Create a test HTTP request that can be used to test your request handler.
pub fn post(path: String, headers: List(#(String, String)), body: String) -> Request(
Connection,
)
Create a test HTTP request that can be used to test your request handler.
pub fn put(path: String, headers: List(#(String, String)), body: String) -> Request(
Connection,
)
Create a test HTTP request that can be used to test your request handler.
pub fn request(method: Method, path: String, headers: List(
#(String, String),
), body: BitString) -> Request(Connection)
Create a test HTTP request that can be used to test your request handler functions.
Note not all HTTP methods are expected to have an accompanying body, so when
using this function directly over other functions such as get
and post
take care to ensure you are not providing a body when it is not expected.
The default_secret_key_base
constant is used as the secret key base for
requests made with this function.
pub fn string_body(response: Response(Body)) -> String
Read the body of a response as a string.
Panics
This function will panic if the response body is a file and the file cannot be read, or if it does not contain valid UTF-8.