use super::debug_snapshot_contracts::LoggingSchemaSnapshotRows;
use super::debug_snapshot_error::LoggingSchemaSnapshotError;
use super::debug_snapshot_queries_result_assembly_input_contracts::LoggingSchemaSnapshotRowsResultAssemblyInput;
use super::debug_snapshot_queries_result_output_handoff_assembly::build_debug_snapshot_query_rows_output_handoff_from_result_assembly;
use super::debug_snapshot_queries_result_output_handoff_input_contracts::LoggingSchemaSnapshotRowsResultOutputHandoffInput;
pub(super) fn build_logging_schema_snapshot_rows_result(
input: LoggingSchemaSnapshotRowsResultAssemblyInput,
) -> Result<LoggingSchemaSnapshotRows, LoggingSchemaSnapshotError> {
let LoggingSchemaSnapshotRowsResultAssemblyInput {
relations_result,
columns_result,
} = input;
let relations = relations_result?;
let columns = columns_result?;
Ok(
build_debug_snapshot_query_rows_output_handoff_from_result_assembly(
LoggingSchemaSnapshotRowsResultOutputHandoffInput { relations, columns },
),
)
}
#[cfg(test)]
mod tests {
use super::*;
use crate::api::schema::debug_snapshot_queries_test_helpers::{
assert_fetch_columns_snapshot_error_for_tests,
assert_fetch_relations_snapshot_error_for_tests,
assert_successful_snapshot_rows_result_for_tests,
build_column_error_snapshot_rows_result_input_for_tests,
build_relation_error_snapshot_rows_result_input_for_tests,
build_successful_snapshot_rows_result_input_for_tests,
};
#[test]
fn snapshot_queries_result_assembly_maps_success_to_snapshot_rows() {
let result = build_logging_schema_snapshot_rows_result(
build_successful_snapshot_rows_result_input_for_tests(),
);
assert_successful_snapshot_rows_result_for_tests(
result,
"snapshot queries result assembly",
);
}
#[test]
fn snapshot_queries_result_assembly_preserves_relation_error_details() {
let result = build_logging_schema_snapshot_rows_result(
build_relation_error_snapshot_rows_result_input_for_tests("relation query failed"),
);
assert_fetch_relations_snapshot_error_for_tests(
result,
Some("relation query failed"),
"snapshot queries result assembly",
);
}
#[test]
fn snapshot_queries_result_assembly_preserves_column_error_details() {
let result = build_logging_schema_snapshot_rows_result(
build_column_error_snapshot_rows_result_input_for_tests("column query failed"),
);
assert_fetch_columns_snapshot_error_for_tests(
result,
Some("column query failed"),
"snapshot queries result assembly",
);
}
}