use super::*;
mod reqwest_client {
use super::*;
#[test]
fn new_creates_client() {
let client = ReqwestClient::new();
let _ = format!("{client:?}");
}
#[test]
fn default_creates_same_as_new() {
let client1 = ReqwestClient::new();
let client2 = ReqwestClient::default();
let _ = format!("{client1:?}");
let _ = format!("{client2:?}");
}
#[test]
fn from_client_accepts_custom_client() {
let custom = reqwest::Client::builder()
.timeout(std::time::Duration::from_secs(30))
.build()
.unwrap();
let client = ReqwestClient::from_client(custom);
let _ = format!("{client:?}");
}
#[test]
fn clone_creates_independent_client() {
let client1 = ReqwestClient::new();
let client2 = client1.clone();
let _ = format!("{client1:?}");
let _ = format!("{client2:?}");
}
#[test]
fn debug_format_is_readable() {
let client = ReqwestClient::new();
let debug = format!("{client:?}");
assert!(debug.contains("ReqwestClient"));
}
#[test]
fn client_is_send_sync() {
fn assert_send_sync<T: Send + Sync>() {}
assert_send_sync::<ReqwestClient>();
}
#[tokio::test]
async fn request_to_invalid_host_returns_error_or_proxy_response() {
let client = ReqwestClient::new();
let url = url::Url::parse("http://invalid.invalid.invalid/").unwrap();
let req = HttpRequest::get(url);
let result = client.request(req).await;
match result {
Err(HttpError::Connection(_)) => {} Ok(resp) if !resp.is_success() => {} other => panic!("Expected connection error or proxy error response, got {other:?}"),
}
}
}