-
Notifications
You must be signed in to change notification settings - Fork 223
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make url as feature and bump version (#419)
* make url usage as feature * bump version * fix: clearer test * Update Cargo.toml Co-authored-by: Daniel Abramov <[email protected]> * Update CHANGELOG.md Co-authored-by: Daniel Abramov <[email protected]> --------- Co-authored-by: Daniel Abramov <[email protected]>
- Loading branch information
1 parent
564f10a
commit c21281a
Showing
9 changed files
with
67 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#![cfg(feature = "handshake")] | ||
#![cfg(feature = "url")] | ||
|
||
use std::{ | ||
assert, | ||
net::TcpListener, | ||
println, | ||
process::exit, | ||
thread::{sleep, spawn}, | ||
time::Duration, | ||
}; | ||
use tungstenite::{ | ||
accept_hdr, connect, | ||
handshake::server::{Request, Response}, | ||
}; | ||
|
||
/// Test for write buffering and flushing behaviour. | ||
#[test] | ||
fn test_with_url() { | ||
env_logger::init(); | ||
// notice the use of url::Url instead of a string | ||
// notice the feature url is activated | ||
let url = url::Url::parse("ws://127.0.0.1:3013").unwrap(); | ||
|
||
spawn(|| { | ||
sleep(Duration::from_secs(5)); | ||
println!("Unit test executed too long, perhaps stuck on WOULDBLOCK..."); | ||
exit(1); | ||
}); | ||
|
||
let server = TcpListener::bind("127.0.0.1:3013").unwrap(); | ||
|
||
let client_thread = spawn(move || { | ||
let conn = connect(url); | ||
assert!(conn.is_ok()); | ||
}); | ||
|
||
let client_handler = server.incoming().next().unwrap(); | ||
|
||
let closing = | ||
accept_hdr(client_handler.unwrap(), |_: &Request, r: Response| Ok(r)).unwrap().close(None); | ||
assert!(closing.is_ok()); | ||
|
||
let result = client_thread.join(); | ||
assert!(result.is_ok()); | ||
} |