use super::debug_contracts::LoggingSchemaDebugReport;
use super::debug_service_loader_output_assembly::build_logging_schema_debug_report_for_client_output;
use super::debug_service_loader_output_input_contracts::LoggingSchemaDebugReportForClientOutputInput;
use super::debug_service_loader_result_assembly_input_contracts::LoggingSchemaDebugReportForClientResultInput;
use super::debug_snapshot_error::LoggingSchemaSnapshotError;
pub(super) fn build_logging_schema_debug_report_for_client_result(
input: LoggingSchemaDebugReportForClientResultInput,
) -> Result<LoggingSchemaDebugReport, LoggingSchemaSnapshotError> {
let LoggingSchemaDebugReportForClientResultInput {
logging_client_name,
snapshot_result,
} = input;
snapshot_result.map(|snapshot| {
build_logging_schema_debug_report_for_client_output(
LoggingSchemaDebugReportForClientOutputInput {
logging_client_name,
snapshot,
},
)
})
}
#[cfg(test)]
mod tests {
use super::*;
use crate::api::schema::debug_service_loader_test_helpers::assert_fetch_columns_snapshot_error_for_tests;
use crate::api::schema::debug_service_loader_test_helpers::assert_successful_service_loader_report_result_for_tests;
use crate::api::schema::debug_service_loader_test_helpers::build_empty_logging_schema_snapshot_for_tests;
#[test]
fn service_loader_result_assembly_maps_snapshot_success_to_report() {
let result = build_logging_schema_debug_report_for_client_result(
LoggingSchemaDebugReportForClientResultInput {
logging_client_name: "athena_logging".to_string(),
snapshot_result: Ok(build_empty_logging_schema_snapshot_for_tests()),
},
);
assert_successful_service_loader_report_result_for_tests(
result,
"service_loader_result_assembly_maps_snapshot_success_to_report",
);
}
#[test]
fn service_loader_result_assembly_preserves_snapshot_error() {
let result = build_logging_schema_debug_report_for_client_result(
LoggingSchemaDebugReportForClientResultInput {
logging_client_name: "athena_logging".to_string(),
snapshot_result: Err(LoggingSchemaSnapshotError::FetchColumns(
sqlx::Error::Protocol("fetch failure".to_string()),
)),
},
);
assert_fetch_columns_snapshot_error_for_tests(
result,
None,
"service_loader_result_assembly_preserves_snapshot_error",
);
}
}