#![cfg(feature = "cachekitio")]
use cachekit::backend::cachekitio::CachekitIO;
#[test]
fn cachekitio_builder() {
let backend = CachekitIO::builder()
.api_key("test-api-key")
.api_url("https://api.example.com")
.allow_custom_host(true)
.build()
.expect("build should succeed");
assert_eq!(backend.api_url(), "https://api.example.com");
}
#[test]
fn cachekitio_builder_missing_api_key() {
let result = CachekitIO::builder()
.api_url("https://api.example.com")
.build();
assert!(result.is_err(), "expected error for missing api_key");
let err = result.unwrap_err().to_string();
assert!(
err.contains("api_key"),
"error message should mention api_key, got: {err}"
);
}
#[test]
fn cachekitio_builder_http_rejected() {
let result = CachekitIO::builder()
.api_key("test-api-key")
.api_url("http://api.example.com")
.build();
assert!(result.is_err(), "expected error for http:// URL");
let err = result.unwrap_err().to_string();
assert!(
err.to_lowercase().contains("https"),
"error message should mention HTTPS, got: {err}"
);
}