#![cfg(feature = "blocking")]
use nolgia::{RetryPolicy, Typed, json};
use uuid::Uuid;
use wiremock::{
Mock, MockServer, ResponseTemplate,
matchers::{method, path},
};
#[test]
fn blocking_client_runs_generated_and_helper_calls() {
let runtime = tokio::runtime::Runtime::new().unwrap();
let id = Uuid::new_v4();
let server = runtime.block_on(async {
let server = MockServer::start().await;
Mock::given(method("GET"))
.and(path("/v1/health"))
.respond_with(ResponseTemplate::new(200).set_body_json(json!({"status": "ok", "version": "t"})))
.mount(&server)
.await;
Mock::given(method("GET"))
.and(path(format!("/v1/jobs/{id}/wait")))
.respond_with(ResponseTemplate::new(200).set_body_json(json!({
"id": id, "user_id": Uuid::nil(), "modality": "image", "model": "m", "status": "succeeded",
"created_at": "2026-10-08T00:00:00Z", "updated_at": "2026-10-08T00:00:00Z"
})))
.mount(&server)
.await;
server
});
let nolgia = nolgia::blocking::Client::from_async(
nolgia::Client::builder()
.api_key("nol_test")
.base_url(server.uri())
.retry(RetryPolicy::none())
.build()
.unwrap(),
)
.unwrap();
let health = nolgia
.block_on(nolgia.api().get_health().send().typed())
.unwrap();
assert_eq!(health.version, "t");
let job = nolgia.wait_job(id, Default::default()).unwrap();
assert_eq!(job.status, "succeeded");
}