kxio/tests/net.rs
Paul Campbell 461e682212
Some checks failed
Rust / build (map[name:stable]) (push) Failing after 7s
Rust / build (map[name:nightly]) (push) Failing after 16s
feat!: fluent api for net
2024-11-08 18:00:59 +00:00

33 lines
778 B
Rust

//
use kxio::net::Error;
type TestResult = Result<(), Error>;
mod get {
use super::*;
#[tokio::test]
async fn test() -> TestResult {
let mut net_mock = kxio::net::mock();
let url = "https://www.example.com";
let request = net_mock.client().get(url).build()?;
let my_response = net_mock.response().status(200).body("OK").unwrap();
net_mock.on(request).response(my_response.clone().into());
let mut net = net_mock.into_net();
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(())
}
}