athena_rs 3.22.1

Hyper performant polyglot Database driver
Documentation
//! Final service-loader payload assembly for `/debug/schema`.
//!
//! This module owns constructing one diagnostics report payload from a
//! resolved logging-client name and a fetched snapshot. Top-level report
//! builder input assembly is delegated to
//! `debug_service_loader_output_report_input_assembly`.

use super::debug_contracts::LoggingSchemaDebugReport;
use super::debug_report::build_logging_schema_debug_report_from_input;
use super::debug_service_loader_output_input_contracts::LoggingSchemaDebugReportForClientOutputInput;
use super::debug_service_loader_output_report_input_assembly::build_debug_service_loader_output_report_input_assembly;

/// Builds one diagnostics report payload from a resolved client and snapshot.
pub(super) fn build_logging_schema_debug_report_for_client_output(
    input: LoggingSchemaDebugReportForClientOutputInput,
) -> LoggingSchemaDebugReport {
    let LoggingSchemaDebugReportForClientOutputInput {
        logging_client_name,
        snapshot,
    } = input;

    let report_builder_input =
        build_debug_service_loader_output_report_input_assembly(logging_client_name, snapshot);

    build_logging_schema_debug_report_from_input(report_builder_input)
}

#[cfg(test)]
mod tests {
    use super::*;
    use crate::api::schema::debug_snapshot_contracts::LoggingSchemaSnapshot;

    #[test]
    /// Preserves the resolved logging-client identity in the assembled report.
    fn output_assembly_preserves_logging_client_name() {
        let report = build_logging_schema_debug_report_for_client_output(
            LoggingSchemaDebugReportForClientOutputInput {
                logging_client_name: "athena_logging".to_string(),
                snapshot: LoggingSchemaSnapshot {
                    relations: vec![],
                    columns: vec![],
                },
            },
        );

        assert_eq!(report.logging_client, "athena_logging");
        assert!(report.observed_tables.is_empty());
    }
}