athena_rs 3.26.2

Hyper performant polyglot Database driver
Documentation
//! Shared `/debug/schema` report fixture builders for module-level tests.
//!
//! These helpers keep test modules focused on stage/response behavior instead
//! of repeating typed report-input construction details.

use super::debug_contracts::LoggingSchemaDebugReport;
use super::debug_report::build_logging_schema_debug_report_from_input;
use super::debug_report_input_contracts::LoggingSchemaDebugReportBuilderInput;
use super::logging_expectation_tables::expected_logging_tables;
use super::service::{SchemaColumnRecord, SchemaRelationRecord};

/// Builds one diagnostics report fixture from explicit relation/column rows.
#[cfg(test)]
pub(crate) fn build_logging_schema_debug_report_fixture_for_tests(
    logging_client: &str,
    relations: Vec<SchemaRelationRecord>,
    columns: Vec<SchemaColumnRecord>,
) -> LoggingSchemaDebugReport {
    build_logging_schema_debug_report_from_input(LoggingSchemaDebugReportBuilderInput {
        logging_client: logging_client.to_string(),
        relations,
        columns,
    })
}

/// Builds the default empty diagnostics report fixture used by stage-response tests.
#[cfg(test)]
pub(crate) fn build_empty_logging_schema_debug_report_for_tests() -> LoggingSchemaDebugReport {
    build_logging_schema_debug_report_fixture_for_tests("athena_logging", vec![], vec![])
}

/// Builds expected relation rows from the static logging-table specification catalog.
#[cfg(test)]
pub(crate) fn build_expected_logging_schema_relations_for_tests(
    include_optional: bool,
) -> Vec<SchemaRelationRecord> {
    expected_logging_tables()
        .iter()
        .filter(|table| include_optional || table.required)
        .map(|table| SchemaRelationRecord {
            table_schema: table.table_schema.to_string(),
            table_name: table.table_name.to_string(),
            relation_type: table.relation_type.to_string(),
        })
        .collect()
}

/// Builds expected column rows from the static logging-table specification catalog.
#[cfg(test)]
pub(crate) fn build_expected_logging_schema_columns_for_tests(
    include_optional: bool,
) -> Vec<SchemaColumnRecord> {
    expected_logging_tables()
        .iter()
        .filter(|table| include_optional || table.required)
        .flat_map(|table| {
            table
                .required_columns
                .iter()
                .map(|column| SchemaColumnRecord {
                    table_schema: table.table_schema.to_string(),
                    table_name: table.table_name.to_string(),
                    column_name: (*column).to_string(),
                    data_type: None,
                    column_default: None,
                    is_nullable: Some("YES".to_string()),
                })
        })
        .collect()
}