athena_rs 3.23.0

Hyper performant polyglot Database driver
Documentation
//! Summary-composition helpers for `/debug/schema` report components.
//!
//! This module builds the intermediate diagnostics summary from expected-table
//! evaluation and still-needed aggregates, including expected-table-count
//! sourcing from `debug_report_components_expected_table_count_stage`.

use super::debug_evaluation::ExpectedTablesEvaluation;
use super::debug_report_components_expected_table_count_stage::build_debug_report_components_expected_table_count;
use super::debug_still_needed::LoggingSchemaDebugStillNeeded;
use super::debug_summary::LoggingSchemaDebugSummary;
use super::debug_summary::build_logging_schema_debug_summary;

/// Builds report-components summary from evaluation and still-needed aggregates.
pub(super) fn build_debug_report_components_summary(
    evaluation: &ExpectedTablesEvaluation,
    still_needed: &LoggingSchemaDebugStillNeeded,
) -> LoggingSchemaDebugSummary {
    build_logging_schema_debug_summary(
        evaluation,
        still_needed,
        build_debug_report_components_expected_table_count(),
    )
}

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

    #[test]
    /// Uses logging expectation catalog size as expected-table count in summary output.
    fn report_components_summary_uses_expected_logging_table_catalog_count() {
        let evaluation = ExpectedTablesEvaluation::default();
        let still_needed = LoggingSchemaDebugStillNeeded {
            required_missing_tables: Vec::new(),
            optional_missing_tables: Vec::new(),
            required_missing_columns: Vec::new(),
            optional_missing_columns: Vec::new(),
            relation_type_mismatches: Vec::new(),
        };

        let summary = build_debug_report_components_summary(&evaluation, &still_needed);

        assert_eq!(
            summary.expected_table_count,
            build_debug_report_components_expected_table_count()
        );
    }
}