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};
#[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,
})
}
#[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![])
}
#[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()
}
#[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()
}