//! Pure health-check logic — no side effects.

use poem_openapi::Object;
use serde::Serialize;

/// The JSON payload returned by the health check endpoint.
#[derive(Serialize, Object)]
pub struct HealthStatus {
    /// Human-readable status string, always `"ok"` when the server is healthy.
    pub status: String,
}

/// Return a healthy status response.
pub fn ok() -> HealthStatus {
    HealthStatus {
        status: "ok".to_string(),
    }
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn ok_returns_status_ok() {
        let s = ok();
        assert_eq!(s.status, "ok");
    }

    #[test]
    fn health_status_serializes() {
        let s = HealthStatus {
            status: "ok".to_string(),
        };
        let json = serde_json::to_value(&s).unwrap();
        assert_eq!(json["status"], "ok");
    }
}
