use super::debug_observed_tables::LoggingSchemaObservedTable;
use super::debug_report_output_metadata_contracts::LoggingSchemaDebugReportOutputMetadata;
use super::debug_report_output_metadata_from_stage_output_assembly::build_logging_schema_debug_report_output_metadata_from_stage_output_assembly;
use super::debug_report_output_metadata_stage_input_assembly::build_debug_report_output_metadata_stage_input_assembly;
use super::debug_report_output_metadata_stage_output_assembly::build_debug_report_output_metadata_stage_output_assembly;
use super::debug_still_needed::LoggingSchemaDebugStillNeeded;
pub(super) fn build_logging_schema_debug_report_output_metadata(
still_needed: &LoggingSchemaDebugStillNeeded,
observed_tables: Vec<LoggingSchemaObservedTable>,
) -> LoggingSchemaDebugReportOutputMetadata {
let stage_input =
build_debug_report_output_metadata_stage_input_assembly(still_needed, observed_tables);
let stage = build_debug_report_output_metadata_stage_output_assembly(stage_input);
build_logging_schema_debug_report_output_metadata_from_stage_output_assembly(stage)
}
#[cfg(test)]
mod tests {
use super::*;
use crate::api::schema::debug_report_output_metadata_test_fixtures::build_metadata_stage_input_parts_for_tests;
#[test]
fn metadata_assembly_preserves_observed_rows_and_legacy_missing_table_keys() {
let (still_needed, observed_tables) = build_metadata_stage_input_parts_for_tests();
let metadata =
build_logging_schema_debug_report_output_metadata(&still_needed, observed_tables);
assert_eq!(metadata.observed_tables.len(), 1);
assert_eq!(
metadata.missing_required_tables,
vec!["public.gateway_request_log".to_string()]
);
assert_eq!(
metadata.missing_optional_tables,
vec!["public.route_request_log".to_string()]
);
assert!(metadata.generated_at.timestamp() > 0);
}
}