use super::debug_contracts::LoggingSchemaDebugReport;
use super::debug_service_error::LoggingSchemaDebugReportError;
use super::debug_snapshot_error::LoggingSchemaSnapshotError;
#[cfg(test)]
pub(crate) fn assert_successful_service_report_result_for_tests(
result: Result<LoggingSchemaDebugReport, LoggingSchemaDebugReportError>,
context: &str,
) {
match result {
Ok(report) => {
assert_eq!(
report.logging_client, "athena_logging",
"unexpected {context} logging_client"
);
assert!(
report.observed_tables.is_empty(),
"expected {context} observed tables to be empty"
);
}
Err(_) => panic!("expected successful service report result for {context}"),
}
}
#[cfg(test)]
pub(crate) fn assert_fetch_snapshot_columns_service_error_for_tests(
result: Result<LoggingSchemaDebugReport, LoggingSchemaDebugReportError>,
expected_source_fragment: Option<&str>,
context: &str,
) {
match result {
Err(LoggingSchemaDebugReportError::FetchSnapshot(
LoggingSchemaSnapshotError::FetchColumns(source),
)) => {
if let Some(fragment) = expected_source_fragment {
assert!(
source.to_string().contains(fragment),
"expected {context} columns source to contain '{fragment}': {source}"
);
}
}
_ => panic!("expected FetchSnapshot(FetchColumns) service error for {context}"),
}
}
#[cfg(test)]
pub(crate) fn assert_fetch_snapshot_relations_service_error_for_tests(
result: Result<LoggingSchemaDebugReport, LoggingSchemaDebugReportError>,
expected_source_fragment: Option<&str>,
context: &str,
) {
match result {
Err(LoggingSchemaDebugReportError::FetchSnapshot(
LoggingSchemaSnapshotError::FetchRelations(source),
)) => {
if let Some(fragment) = expected_source_fragment {
assert!(
source.to_string().contains(fragment),
"expected {context} relations source to contain '{fragment}': {source}"
);
}
}
_ => panic!("expected FetchSnapshot(FetchRelations) service error for {context}"),
}
}