use super::debug_snapshot_contracts::{LoggingSchemaSnapshot, LoggingSchemaSnapshotRows};
pub(super) fn build_logging_schema_snapshot_output(
rows: LoggingSchemaSnapshotRows,
) -> LoggingSchemaSnapshot {
LoggingSchemaSnapshot {
relations: rows.relations,
columns: rows.columns,
}
}
#[cfg(test)]
mod tests {
use super::*;
use crate::api::schema::service::{SchemaColumnRecord, SchemaRelationRecord};
#[test]
fn snapshot_output_preserves_relation_and_column_rows() {
let rows = LoggingSchemaSnapshotRows {
relations: vec![SchemaRelationRecord {
table_schema: "public".to_string(),
table_name: "gateway_request_log".to_string(),
relation_type: "BASE TABLE".to_string(),
}],
columns: vec![SchemaColumnRecord {
table_schema: "public".to_string(),
table_name: "gateway_request_log".to_string(),
column_name: "request_id".to_string(),
data_type: Some("uuid".to_string()),
column_default: None,
is_nullable: Some("NO".to_string()),
}],
};
let snapshot = build_logging_schema_snapshot_output(rows);
assert_eq!(snapshot.relations.len(), 1);
assert_eq!(snapshot.columns.len(), 1);
assert_eq!(snapshot.relations[0].table_name, "gateway_request_log");
assert_eq!(snapshot.columns[0].column_name, "request_id");
}
}