#![allow(dead_code)]
use std::time::Duration;
use reasoninglayer::{AuthConfig, ClientConfig, ReasoningLayerClient};
use uuid::Uuid;
pub fn backend_url() -> String {
std::env::var("RL_BACKEND_URL").unwrap_or_else(|_| "http://localhost:8083".to_string())
}
pub fn fresh_tenant() -> String {
Uuid::new_v4().to_string()
}
pub fn build_client(tenant_id: &str) -> ReasoningLayerClient {
let config = ClientConfig::new(backend_url(), tenant_id, AuthConfig::Cookie)
.with_timeout(Duration::from_secs(30))
.with_max_retries(1);
ReasoningLayerClient::new(config).expect("client builds")
}
pub async fn cleanup(client: &ReasoningLayerClient, tenant_id: &str) {
if let Err(err) = client.admin().clear_tenant_data(tenant_id, None).await {
eprintln!("[cleanup] failed to clear tenant {tenant_id}: {err}");
}
}
pub async fn require_backend(client: &ReasoningLayerClient) {
if let Err(err) = client.health().check(None).await {
panic!(
"[require_backend] {} not reachable: {err}\n\
Set RL_BACKEND_URL to point at a running backend, or remove `--ignored` to skip.",
backend_url()
);
}
}