use axum::http::StatusCode;

use crate::services;

pub async fn health_check() -> StatusCode {
    match services::health_check().await {
        Ok(_) => StatusCode::NO_CONTENT,
        Err(e) => {
            tracing::error!("{e}");
            StatusCode::INTERNAL_SERVER_ERROR
        }
    }
}

#[cfg(test)]
mod tests {
    use axum::http::StatusCode;

    #[tokio::test]
    async fn correct_code_from_successful_check() {
        let code = super::health_check().await;

        assert_eq!(code, StatusCode::NO_CONTENT);
    }
}
