use actix_web::HttpResponse;
use super::catalog_errors::schema_internal_fetch_error;
pub(super) fn map_snapshot_fetch_relations_error_response(err: &sqlx::Error) -> HttpResponse {
schema_internal_fetch_error("logging schema tables", err)
}
pub(super) fn map_snapshot_fetch_columns_error_response(err: &sqlx::Error) -> HttpResponse {
schema_internal_fetch_error("logging schema columns", err)
}
#[cfg(test)]
mod tests {
use super::*;
use crate::api::schema::debug_snapshot_fetch_error_response_test_helpers::{
assert_snapshot_fetch_columns_error_response_for_tests,
assert_snapshot_fetch_relations_error_response_for_tests,
};
#[actix_web::test]
async fn variant_mapper_maps_relations_fetch_error_to_internal_error() {
let response = map_snapshot_fetch_relations_error_response(&sqlx::Error::Protocol(
"relations failed".to_string(),
));
assert_snapshot_fetch_relations_error_response_for_tests(
response,
"relations failed",
"snapshot fetch variant mapper relations",
)
.await;
}
#[actix_web::test]
async fn variant_mapper_maps_columns_fetch_error_to_internal_error() {
let response = map_snapshot_fetch_columns_error_response(&sqlx::Error::Protocol(
"columns failed".to_string(),
));
assert_snapshot_fetch_columns_error_response_for_tests(
response,
"columns failed",
"snapshot fetch variant mapper columns",
)
.await;
}
}