athena_rs 3.22.1

Hyper performant polyglot Database driver
Documentation
//! Shared `/debug/schema` service-result handoff assertion helpers.
//!
//! These helpers centralize repeated stage-output handoff assertions so
//! service-result handoff modules can focus on which handoff boundary they
//! verify instead of reimplementing identical success/error fixture flows.

use super::debug_contracts::LoggingSchemaDebugReport;
use super::debug_service_error::LoggingSchemaDebugReportError;
use super::debug_service_result_stage_contracts::LoggingSchemaDebugReportServiceResultStage;
use super::debug_service_result_stage_test_helpers::{
    build_fetch_columns_service_result_stage_for_tests,
    build_fetch_relations_service_result_stage_for_tests,
    build_successful_service_result_stage_for_tests,
};
use super::debug_service_result_test_helpers::{
    assert_fetch_snapshot_columns_service_error_for_tests,
    assert_fetch_snapshot_relations_service_error_for_tests,
    assert_successful_service_report_result_for_tests,
};

/// Shared function signature for one service-result stage-output handoff boundary.
#[cfg(test)]
pub(crate) type LoggingSchemaDebugReportServiceResultStageHandoffFn =
    fn(
        LoggingSchemaDebugReportServiceResultStage,
    ) -> Result<LoggingSchemaDebugReport, LoggingSchemaDebugReportError>;

/// Asserts one stage-output handoff preserves successful staged report payloads.
#[cfg(test)]
pub(crate) fn assert_service_result_stage_handoff_preserves_success_for_tests(
    handoff: LoggingSchemaDebugReportServiceResultStageHandoffFn,
    context: &str,
) {
    let result = handoff(build_successful_service_result_stage_for_tests());
    assert_successful_service_report_result_for_tests(result, context);
}

/// Asserts one stage-output handoff maps `FetchColumns` staged failures to
/// service-layer snapshot error variants.
#[cfg(test)]
pub(crate) fn assert_service_result_stage_handoff_maps_columns_error_for_tests(
    handoff: LoggingSchemaDebugReportServiceResultStageHandoffFn,
    source_message: &str,
    expected_source_fragment: Option<&str>,
    context: &str,
) {
    let result = handoff(build_fetch_columns_service_result_stage_for_tests(
        source_message,
    ));
    assert_fetch_snapshot_columns_service_error_for_tests(
        result,
        expected_source_fragment,
        context,
    );
}

/// Asserts one stage-output handoff maps `FetchRelations` staged failures to
/// service-layer snapshot error variants.
#[cfg(test)]
pub(crate) fn assert_service_result_stage_handoff_maps_relations_error_for_tests(
    handoff: LoggingSchemaDebugReportServiceResultStageHandoffFn,
    source_message: &str,
    expected_source_fragment: Option<&str>,
    context: &str,
) {
    let result = handoff(build_fetch_relations_service_result_stage_for_tests(
        source_message,
    ));
    assert_fetch_snapshot_relations_service_error_for_tests(
        result,
        expected_source_fragment,
        context,
    );
}