use cloudllm::clients::common::get_shared_http_client;
#[test]
fn test_shared_http_client_is_singleton() {
let client1 = get_shared_http_client();
let client2 = get_shared_http_client();
let client3 = get_shared_http_client();
let ptr1 = client1 as *const _;
let ptr2 = client2 as *const _;
let ptr3 = client3 as *const _;
assert_eq!(
ptr1, ptr2,
"All clients should point to the same singleton instance"
);
assert_eq!(
ptr2, ptr3,
"All clients should point to the same singleton instance"
);
}
#[test]
fn test_shared_http_client_has_pooling_config() {
let client = get_shared_http_client();
let _cloned = client.clone();
}
#[tokio::test]
async fn test_multiple_clients_share_connection_pool() {
use cloudllm::clients::openai::OpenAIClient;
use cloudllm::ClientWrapper;
let client1 = OpenAIClient::new_with_model_string("dummy_key_1", "gpt-4");
let client2 = OpenAIClient::new_with_model_string("dummy_key_2", "gpt-4");
let client3 = OpenAIClient::new_with_model_string("dummy_key_3", "gpt-4");
assert_eq!(client1.model_name(), "gpt-4");
assert_eq!(client2.model_name(), "gpt-4");
assert_eq!(client3.model_name(), "gpt-4");
}
#[tokio::test]
async fn test_gemini_client_uses_shared_pool() {
use cloudllm::clients::gemini::GeminiClient;
use cloudllm::ClientWrapper;
let client = GeminiClient::new_with_model_string("dummy_key", "gemini-2.0-flash");
assert_eq!(client.model_name(), "gemini-2.0-flash");
}