refrakt/testing
Test helpers for Refrakt applications.
Build test requests without a running HTTP server.
Example
import refrakt/testing
pub fn index_returns_200_test() {
let req = testing.get("/posts")
let resp = post_handler.index(req, test_ctx())
resp.status |> should.equal(200)
}
Values
pub fn assert_header(
resp: response.Response(String),
name: String,
expected: String,
) -> Bool
Check that a response has a specific header value.
pub fn assert_status(
resp: response.Response(String),
expected: Int,
) -> Bool
Check that a response has a specific status code.
pub fn delete(path: String) -> request.Request(String)
Create a DELETE request for testing.
pub fn request(
method: http.Method,
path: String,
) -> request.Request(String)
Create a request with a specific method and path.
pub fn with_body(
req: request.Request(String),
body: String,
) -> request.Request(String)
Set the body of a test request.
pub fn with_header(
req: request.Request(String),
name: String,
value: String,
) -> request.Request(String)
Add a header to a test request.