Struct gotham::plain::test::TestServer [−][src]
pub struct TestServer { /* fields omitted */ }
Expand description
The TestServer
type, which is used as a harness when writing test cases for Hyper services
(which Gotham’s Router
is). An instance of TestServer
is run asynchronously within the
current thread, and is only accessible by a client returned from the TestServer
.
Examples
use gotham::test::TestServer;
let test_server = TestServer::new(|| Ok(my_handler)).unwrap();
let response = test_server.client().get("http://localhost/").perform().unwrap();
assert_eq!(response.status(), StatusCode::ACCEPTED);
Implementations
Creates a TestServer
instance for the Handler
spawned by new_handler
. This server has
the same guarantee given by hyper::server::Http::bind
, that a new service will be spawned
for each connection.
Timeout will be set to 10 seconds.
pub fn with_timeout<NH: NewHandler + 'static>(
new_handler: NH,
timeout: u64
) -> Result<TestServer>
pub fn with_timeout<NH: NewHandler + 'static>(
new_handler: NH,
timeout: u64
) -> Result<TestServer>
Sets the request timeout to timeout
seconds and returns a new TestServer
.
Returns a client connected to the TestServer
. The transport is handled internally.
Trait Implementations
Runs a Future until it resolves.
Returns a Delay that will expire when a request should.
Auto Trait Implementations
impl RefUnwindSafe for TestServer
impl Send for TestServer
impl Sync for TestServer
impl Unpin for TestServer
impl UnwindSafe for TestServer
Blanket Implementations
Mutably borrows from an owned value. Read more
pub fn vzip(self) -> V
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more