athena_rs 3.26.4

Hyper performant polyglot Database driver
Documentation
//! Final report-output input assembly for `/debug/schema`.
//!
//! This module isolates construction of typed final report-output input payloads
//! from staged handoff modules so handoff orchestration can focus on variant-
//! specific projection policy.

use super::debug_contracts::LoggingSchemaDebugSummary;
use super::debug_evaluation::ExpectedTablesEvaluation;
use super::debug_observed_table_contracts::ObservedTablesMap;
use super::debug_report_output_input_contracts::LoggingSchemaDebugReportOutputInput;
use super::debug_still_needed::LoggingSchemaDebugStillNeeded;

/// Builds typed final report-output input payloads from projected diagnostics parts.
pub(super) fn build_debug_report_output_input_assembly(
    logging_client: String,
    summary: LoggingSchemaDebugSummary,
    evaluation: ExpectedTablesEvaluation,
    still_needed: LoggingSchemaDebugStillNeeded,
    observed_map: ObservedTablesMap,
) -> LoggingSchemaDebugReportOutputInput {
    LoggingSchemaDebugReportOutputInput {
        logging_client,
        summary,
        evaluation,
        still_needed,
        observed_map,
    }
}

#[cfg(test)]
mod tests {
    use super::*;
    use crate::api::schema::debug_report_output_projection_test_fixtures::{
        build_report_output_projection_expected_table_evaluation_for_tests,
        build_report_output_projection_observed_map_with_gateway_request_for_tests,
        build_report_output_projection_still_needed_empty_for_tests,
        build_report_output_projection_summary_healthy_for_tests,
    };

    #[test]
    /// Preserves projected diagnostics fields when assembling final report-output input payloads.
    fn report_output_input_assembly_preserves_fields() {
        let logging_client = "athena_logging".to_string();
        let summary = build_report_output_projection_summary_healthy_for_tests(1);
        let evaluation = build_report_output_projection_expected_table_evaluation_for_tests();
        let still_needed = build_report_output_projection_still_needed_empty_for_tests();
        let observed_map =
            build_report_output_projection_observed_map_with_gateway_request_for_tests();

        let input = build_debug_report_output_input_assembly(
            logging_client,
            summary,
            evaluation,
            still_needed,
            observed_map,
        );

        assert_eq!(input.logging_client, "athena_logging");
        assert_eq!(input.summary.health, "healthy");
        assert_eq!(input.evaluation.expected_tables.len(), 1);
        assert!(input.still_needed.required_missing_tables.is_empty());
        assert_eq!(input.observed_map.len(), 1);
    }
}