use super::debug_snapshot_error::LoggingSchemaSnapshotError;
pub(super) fn map_snapshot_relations_fetch_error(err: sqlx::Error) -> LoggingSchemaSnapshotError {
LoggingSchemaSnapshotError::FetchRelations(err)
}
pub(super) fn map_snapshot_columns_fetch_error(err: sqlx::Error) -> LoggingSchemaSnapshotError {
LoggingSchemaSnapshotError::FetchColumns(err)
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn mapper_wraps_relation_query_error() {
let err = map_snapshot_relations_fetch_error(sqlx::Error::Protocol(
"relations failed".to_string(),
));
match err {
LoggingSchemaSnapshotError::FetchRelations(_) => {}
LoggingSchemaSnapshotError::FetchColumns(_) => {
panic!("expected FetchRelations variant")
}
}
}
#[test]
fn mapper_wraps_column_query_error() {
let err =
map_snapshot_columns_fetch_error(sqlx::Error::Protocol("columns failed".to_string()));
match err {
LoggingSchemaSnapshotError::FetchColumns(_) => {}
LoggingSchemaSnapshotError::FetchRelations(_) => {
panic!("expected FetchColumns variant")
}
}
}
}