use crate::api::misc_handlers::readiness;
use axum::http::StatusCode;
const REASON: &str = "kernel launch failed (716), and a no-op synchronize also failed";
#[test]
fn a_loaded_model_with_no_fault_is_ready() {
let (code, body) = readiness(Some("Qwen/Qwen3.6-27B-NVFP4"), None);
assert_eq!(code, StatusCode::OK);
assert_eq!(body["status"], "ready");
assert_eq!(body["model"], "Qwen/Qwen3.6-27B-NVFP4");
}
#[test]
fn no_model_and_no_fault_is_still_loading() {
let (code, body) = readiness(None, None);
assert_eq!(code, StatusCode::SERVICE_UNAVAILABLE);
assert_eq!(body["status"], "loading");
}
#[test]
fn a_fault_outranks_a_published_model() {
let (code, body) = readiness(Some("Qwen/Qwen3.6-27B-NVFP4"), Some(REASON));
assert_eq!(
code,
StatusCode::SERVICE_UNAVAILABLE,
"a published model on a dead context is NOT ready"
);
assert_eq!(body["status"], "faulted");
}
#[test]
fn the_fault_body_carries_the_reason() {
let (_, body) = readiness(None, Some(REASON));
assert_eq!(body["reason"], REASON);
}
#[test]
fn a_fault_before_any_model_loaded_is_not_reported_as_loading() {
let (code, body) = readiness(None, Some(REASON));
assert_eq!(code, StatusCode::SERVICE_UNAVAILABLE);
assert_eq!(
body["status"], "faulted",
"a permanently dead server must not look like a starting one"
);
}