mirror of
https://github.com/actix/actix-extras.git
synced 2024-11-24 07:53:00 +01:00
feature: allow TestServer to open a websocket on any URL
* added `TestServer::ws_at(uri_str)` * modified `TestServer::ws()` to call `self.ws_at("/")` to preserve behavior Closes #432
This commit is contained in:
parent
2071ea0532
commit
aa1e75f071
16
src/test.rs
16
src/test.rs
@ -207,13 +207,21 @@ impl TestServer {
|
||||
self.rt.block_on(fut)
|
||||
}
|
||||
|
||||
/// Connect to websocket server
|
||||
/// Connect to websocket server at a given path
|
||||
pub fn ws_at(
|
||||
&mut self,
|
||||
path: &str,
|
||||
) -> Result<(ws::ClientReader, ws::ClientWriter), ws::ClientError> {
|
||||
let url = self.url(path);
|
||||
self.rt
|
||||
.block_on(ws::Client::with_connector(url, self.conn.clone()).connect())
|
||||
}
|
||||
|
||||
/// Connect to a websocket server
|
||||
pub fn ws(
|
||||
&mut self,
|
||||
) -> Result<(ws::ClientReader, ws::ClientWriter), ws::ClientError> {
|
||||
let url = self.url("/");
|
||||
self.rt
|
||||
.block_on(ws::Client::with_connector(url, self.conn.clone()).connect())
|
||||
self.ws_at("/")
|
||||
}
|
||||
|
||||
/// Create `GET` request
|
||||
|
Loading…
Reference in New Issue
Block a user