2
0
Fork 1
mirror of https://github.com/async-rs/async-std.git synced 2025-01-16 18:59:55 +00:00
async-std/tests/verbose_errors.rs
Pascal Hertleif 56538ebd91 Improve verbose errors for socket addresses
Moves the point of adding error context to the net::addr module so that
we have access to the raw address input and can include it in the error
message.
2019-11-25 23:30:31 +01:00

31 lines
1.1 KiB
Rust

use async_std::{fs, io, net::ToSocketAddrs, task};
#[test]
fn open_file() {
task::block_on(async {
let non_existing_file = "/ashjudlkahasdasdsikdhajik/asdasdasdasdasdasd/fjuiklashdbflasas";
let res = fs::File::open(non_existing_file).await;
match res {
Ok(_) => panic!("Found file with random name: We live in a simulation"),
Err(e) => assert_eq!(
"Could not open `/ashjudlkahasdasdsikdhajik/asdasdasdasdasdasd/fjuiklashdbflasas`",
&format!("{}", e)
),
}
})
}
#[test]
fn resolve_address() {
task::block_on(async {
let non_existing_addr = "ashjudlkahasdasdsikdhajik.asdasdasdasdasdasd.fjuiklashdbflasas:80";
let res: Result<_, io::Error> = non_existing_addr.to_socket_addrs().await;
match res {
Ok(_) => panic!("Found address with random name: We live in a simulation"),
Err(e) => assert_eq!(
"could not resolve address `\"ashjudlkahasdasdsikdhajik.asdasdasdasdasdasd.fjuiklashdbflasas:80\"`",
&format!("{}", e)
),
}
})
}