kxio/tests/net.rs

33 lines
715 B
Rust
Raw Normal View History

2024-11-04 10:22:31 +00:00
//
use kxio::net::Error;
type TestResult = Result<(), Error>;
mod get {
use super::*;
#[tokio::test]
async fn test() -> TestResult {
let mut net = kxio::net::mock();
2024-11-04 10:22:31 +00:00
let url = "https://www.example.com";
let request = net.client().get(url).build()?;
let my_response = net.response().status(200).body("OK").unwrap();
2024-11-04 10:22:31 +00:00
net.on(request).response(my_response.clone().into());
2024-11-04 10:22:31 +00:00
let client = net.client();
let response = net.send(client.get(url)).await?;
assert_eq!(response.status(), my_response.status());
// net_mock.assert()?;
// let my_net = net::new();
// my_net.send(request).await?;
Ok(())
}
}