Module tsukuyomi::local [−][src]
A testing framework for Tsukuyomi.
Examples
use tsukuyomi::local::LocalServer; let app = App::builder() .route(("/hello", handler::wrap_ready(|_| "Hello"))) .finish() .unwrap(); // Create a local server from an App. // The instance emulates the behavior of an HTTP service // without the low level I/O. let mut server = LocalServer::new(app).unwrap(); // Emulate an HTTP request and retrieve its response. let response = server.client() .get("/hello") .execute() .unwrap(); // Do some stuff... assert_eq!(response.status(), StatusCode::OK); assert!(response.headers().contains_key(header::CONTENT_TYPE)); assert_eq!(*response.body().to_bytes(), b"Hello"[..]);
Structs
Client |
A type which emulates a connection to a peer. |
Data |
A type representing a received HTTP message data from the server. |
LocalRequest |
A type which emulates an HTTP request from a peer. |
LocalServer |
A local server which emulates an HTTP service without using the low-level transport. |
RequestBody |