use actix_web::HttpResponse;
use crate::AppState;
use super::debug_response::debug_schema_response;
pub(super) async fn build_debug_schema_handler_response(app_state: &AppState) -> HttpResponse {
debug_schema_response(app_state).await
}
#[cfg(test)]
mod tests {
use actix_web::http::StatusCode;
use super::*;
use crate::api::schema::debug_response_test_helpers::{
assert_error_payload_for_tests, response_json_for_tests,
};
#[actix_web::test]
async fn handler_output_handoff_returns_service_unavailable_when_logging_client_missing() {
let app_state = AppState::default();
let response = build_debug_schema_handler_response(&app_state).await;
assert_eq!(response.status(), StatusCode::SERVICE_UNAVAILABLE);
let body =
response_json_for_tests(response, "handler output handoff missing logging client")
.await;
assert_error_payload_for_tests(
&body,
"Logging store unavailable",
&["No athena logging client is configured."],
"handler output handoff missing logging client",
);
}
#[actix_web::test]
async fn handler_output_handoff_returns_service_unavailable_when_logging_client_disconnected() {
let mut app_state = AppState::default();
app_state.logging_client_name = Some("athena_logging".to_string());
let response = build_debug_schema_handler_response(&app_state).await;
assert_eq!(response.status(), StatusCode::SERVICE_UNAVAILABLE);
let body = response_json_for_tests(
response,
"handler output handoff disconnected logging client",
)
.await;
assert_error_payload_for_tests(
&body,
"Logging store unavailable",
&["Logging client 'athena_logging' is not connected."],
"handler output handoff disconnected logging client",
);
}
}