Module finchers::test [−][src]
The basic facilities for testing endpoints.
Example
let endpoint = path!(@get / "greeting" / String) .map(|name: String| format!("Hello, {}.", name)); // Create an instance of TestRunner from an endpoint. let mut runner = test::runner(endpoint); let response = runner .perform("http://www.example.com/greeting/Alice") .unwrap(); assert_eq!(response.status().as_u16(), 200); assert!(response.headers().contains_key("content-type")); assert_eq!(response.body().to_utf8().unwrap(), "Hello, Alice.");
Validates the result of the endpoint without converting to HTTP response.
use finchers::error::Result; // A user-defined type which does not implement `Output`. struct Credential; let endpoint = endpoint::unit().map(|| Credential); let mut runner = test::runner(endpoint); let result: Result<Credential> = runner.apply("/"); assert!(result.is_ok());
Structs
TestRunner |
A test runner for emulating the behavior of endpoints in the server. |
Enums
TestResult |
A struct representing a response body returned from the test runner. |
Traits
IntoReqBody |
A trait representing the conversion into a message body in HTTP requests. |
TestRequest |
A trait representing the conversion into an HTTP request. |
Functions
runner |
A helper function for creating a new |