evento-sql 2.0.0-alpha.30

SQL database implementations for evento event sourcing library.
use evento::sql::Sql;
use sqlx::PgPool;

mod pool;

#[tokio::test]
async fn postgres_routing_key() -> anyhow::Result<()> {
    let executor = create_postgres_executor("routing_key").await?;

    evento_test::routing_key(&executor).await
}

#[tokio::test]
async fn postgres_load() -> anyhow::Result<()> {
    let executor = create_postgres_executor("load").await?;

    evento_test::load(&executor).await
}

#[tokio::test]
async fn postgres_load_multiple_aggregator() -> anyhow::Result<()> {
    let executor = create_postgres_executor("load_multiple_aggregator").await?;

    evento_test::load_multiple_aggregator(&executor).await
}

#[tokio::test]
async fn postgres_load_with_snapshot() -> anyhow::Result<()> {
    let executor = create_postgres_executor("load_with_snapshot").await?;

    evento_test::load_with_snapshot(&executor).await
}

#[tokio::test]
async fn postgres_invalid_original_version() -> anyhow::Result<()> {
    let executor = create_postgres_executor("invalid_original_version").await?;

    evento_test::invalid_original_version(&executor).await
}

#[tokio::test]
async fn postgres_subscriber_running() -> anyhow::Result<()> {
    let pool = create_postgres_pool("subscriber_running").await?;

    evento_test::subscriber_running::<Sql<sqlx::Postgres>>(&pool.into()).await
}

#[tokio::test]
async fn postgres_subscribe() -> anyhow::Result<()> {
    let pool = create_postgres_pool("subscribe").await?;

    evento_test::subscribe::<Sql<sqlx::Postgres>>(&pool.into()).await
}

#[tokio::test]
async fn postgres_subscribe_routing_key() -> anyhow::Result<()> {
    let pool = create_postgres_pool("subscribe_routing_key").await?;

    evento_test::subscribe_routing_key::<Sql<sqlx::Postgres>>(&pool.into()).await
}

#[tokio::test]
async fn postgres_subscribe_default() -> anyhow::Result<()> {
    let pool = create_postgres_pool("subscribe_default").await?;

    evento_test::subscribe_default::<Sql<sqlx::Postgres>>(&pool.into()).await
}

#[tokio::test]
async fn postgres_subscribe_multiple_aggregator() -> anyhow::Result<()> {
    let pool = create_postgres_pool("subscribe_multiple_aggregator").await?;

    evento_test::subscribe_multiple_aggregator::<Sql<sqlx::Postgres>>(&pool.into()).await
}

#[tokio::test]
async fn postgres_subscribe_co_keyed_aggregator() -> anyhow::Result<()> {
    let pool = create_postgres_pool("subscribe_co_keyed_aggregator").await?;

    evento_test::subscribe_co_keyed_aggregator::<Sql<sqlx::Postgres>>(&pool.into()).await
}

#[tokio::test]
async fn postgres_load_co_keyed_aggregator() -> anyhow::Result<()> {
    let pool = create_postgres_pool("load_co_keyed_aggregator").await?;

    evento_test::load_co_keyed_aggregator::<Sql<sqlx::Postgres>>(&pool.into()).await
}

#[tokio::test]
async fn postgres_subscribe_routing_key_multiple_aggregator() -> anyhow::Result<()> {
    let pool = create_postgres_pool("subscribe_routing_key_multiple_aggregator").await?;

    evento_test::subscribe_routing_key_multiple_aggregator::<Sql<sqlx::Postgres>>(&pool.into())
        .await
}

#[tokio::test]
async fn postgres_subscribe_default_multiple_aggregator() -> anyhow::Result<()> {
    let pool = create_postgres_pool("subscribe_default_multiple_aggregator").await?;

    evento_test::subscribe_default_multiple_aggregator::<Sql<sqlx::Postgres>>(&pool.into()).await
}

#[tokio::test]
async fn postgres_all_commands() -> anyhow::Result<()> {
    let pool = create_postgres_pool("all_commands").await?;

    evento_test::all_commands::<Sql<sqlx::Postgres>>(&pool.into()).await
}

#[tokio::test]
async fn postgres_forward_asc() -> anyhow::Result<()> {
    let pool = create_postgres_pool("forward_asc").await?;

    pool::forward_asc(pool).await
}

#[tokio::test]
async fn postgres_forward_desc() -> anyhow::Result<()> {
    let pool = create_postgres_pool("forward_desc").await?;

    pool::forward_desc(pool).await
}

#[tokio::test]
async fn postgres_backward_asc() -> anyhow::Result<()> {
    let pool = create_postgres_pool("backward_asc").await?;

    pool::backward_asc(pool).await
}

#[tokio::test]
async fn postgres_backward_desc() -> anyhow::Result<()> {
    let pool = create_postgres_pool("backward_desc").await?;

    pool::backward_desc(pool).await
}

async fn create_postgres_executor(key: impl Into<String>) -> anyhow::Result<Sql<sqlx::Postgres>> {
    Ok(create_postgres_pool(key).await?.into())
}

async fn create_postgres_pool(key: impl Into<String>) -> anyhow::Result<PgPool> {
    let key = key.into();
    let url = format!("postgres://postgres:postgres@localhost:5432/{key}");

    pool::create_pool(url).await
}

#[tokio::test]
async fn postgres_read_order_timestamp() -> anyhow::Result<()> {
    let executor = create_postgres_executor("read_order_timestamp").await?;
    evento_test::read_order_timestamp(&executor).await
}

#[tokio::test]
async fn postgres_exact_filter() -> anyhow::Result<()> {
    let executor = create_postgres_executor("exact_filter").await?;
    evento_test::exact_filter(&executor).await
}

#[tokio::test]
async fn postgres_write_restamps_client_clock() -> anyhow::Result<()> {
    let executor = create_postgres_executor("write_restamps_client_clock").await?;
    evento_test::write_restamps_client_clock(&executor).await
}

#[tokio::test]
async fn postgres_concurrent_append() -> anyhow::Result<()> {
    let executor = create_postgres_executor("concurrent_append").await?;
    evento_test::concurrent_append(&executor).await
}

#[tokio::test]
async fn postgres_strict_unhandled() -> anyhow::Result<()> {
    let executor = create_postgres_executor("strict_unhandled").await?;
    evento_test::strict_unhandled(&executor).await
}

#[tokio::test]
async fn postgres_tombstone() -> anyhow::Result<()> {
    let executor = create_postgres_executor("tombstone").await?;
    evento_test::tombstone(&executor).await
}

#[tokio::test]
async fn postgres_subscription_data() -> anyhow::Result<()> {
    let executor = create_postgres_executor("subscription_data").await?;
    evento_test::subscription_data(&executor).await
}

#[tokio::test]
async fn postgres_subscription_stop_reason() -> anyhow::Result<()> {
    let executor = create_postgres_executor("subscription_stop_reason").await?;
    evento_test::subscription_stop_reason(&executor).await
}

#[tokio::test]
async fn postgres_subscription_all_counts() -> anyhow::Result<()> {
    let executor = create_postgres_executor("subscription_all_counts").await?;
    evento_test::subscription_all_counts(&executor).await
}

#[tokio::test]
async fn postgres_snapshot_revision_scope() -> anyhow::Result<()> {
    let executor = create_postgres_executor("snapshot_revision_scope").await?;
    evento_test::snapshot_revision_scope(&executor).await
}

#[tokio::test]
async fn postgres_snapshot_projection_scope() -> anyhow::Result<()> {
    let executor = create_postgres_executor("snapshot_projection_scope").await?;
    evento_test::snapshot_projection_scope(&executor).await
}

#[tokio::test]
async fn postgres_upcast_load() -> anyhow::Result<()> {
    let executor = create_postgres_executor("upcast_load").await?;
    evento_test::upcast_load(&executor).await
}

#[tokio::test]
async fn postgres_upcast_nearest_target() -> anyhow::Result<()> {
    let executor = create_postgres_executor("upcast_nearest_target").await?;
    evento_test::upcast_nearest_target(&executor).await
}

#[tokio::test]
async fn postgres_upcast_explicit_wins() -> anyhow::Result<()> {
    let executor = create_postgres_executor("upcast_explicit_wins").await?;
    evento_test::upcast_explicit_wins(&executor).await
}

#[tokio::test]
async fn postgres_upcast_skip() -> anyhow::Result<()> {
    let executor = create_postgres_executor("upcast_skip").await?;
    evento_test::upcast_skip(&executor).await
}

#[tokio::test]
async fn postgres_upcast_strict_unhandled_target() -> anyhow::Result<()> {
    let executor = create_postgres_executor("upcast_strict_unhandled_target").await?;
    evento_test::upcast_strict_unhandled_target(&executor).await
}

#[tokio::test]
async fn postgres_upcast_subscription() -> anyhow::Result<()> {
    let executor = create_postgres_executor("upcast_subscription").await?;
    evento_test::upcast_subscription(&executor).await
}

#[tokio::test]
async fn postgres_upcast_projection_subscription() -> anyhow::Result<()> {
    let executor = create_postgres_executor("upcast_projection_subscription").await?;
    evento_test::upcast_projection_subscription(&executor).await
}

#[tokio::test]
async fn postgres_upcast_tombstone() -> anyhow::Result<()> {
    let executor = create_postgres_executor("upcast_tombstone").await?;
    evento_test::upcast_tombstone(&executor).await
}

#[tokio::test]
async fn postgres_upcast_has_event() -> anyhow::Result<()> {
    let executor = create_postgres_executor("upcast_has_event").await?;
    evento_test::upcast_has_event(&executor).await
}

#[tokio::test]
async fn postgres_read_stream() -> anyhow::Result<()> {
    let executor = create_postgres_executor("read_stream").await?;
    evento_test::read_stream(&executor).await
}

#[tokio::test]
async fn postgres_read_drains_pages() -> anyhow::Result<()> {
    let executor = create_postgres_executor("read_drains_pages").await?;
    evento_test::read_drains_pages(&executor).await
}

#[tokio::test]
async fn postgres_read_limit() -> anyhow::Result<()> {
    let executor = create_postgres_executor("read_limit").await?;
    evento_test::read_limit(&executor).await
}

#[tokio::test]
async fn postgres_read_page_cursor() -> anyhow::Result<()> {
    let executor = create_postgres_executor("read_page_cursor").await?;
    evento_test::read_page_cursor(&executor).await
}

#[tokio::test]
async fn postgres_read_decode() -> anyhow::Result<()> {
    let executor = create_postgres_executor("read_decode").await?;
    evento_test::read_decode(&executor).await
}

#[tokio::test]
async fn postgres_read_routing_key() -> anyhow::Result<()> {
    let executor = create_postgres_executor("read_routing_key").await?;
    evento_test::read_routing_key(&executor).await
}

#[tokio::test]
async fn postgres_subscription_start_from_latest() -> anyhow::Result<()> {
    let executor = create_postgres_executor("sub_start_from_latest").await?;
    evento_test::subscription_start_from_latest(&executor).await
}

#[tokio::test]
async fn postgres_subscription_ephemeral() -> anyhow::Result<()> {
    let executor = create_postgres_executor("sub_ephemeral").await?;
    evento_test::subscription_ephemeral(&executor).await
}

#[tokio::test]
async fn postgres_subscription_ephemeral_start_from_latest() -> anyhow::Result<()> {
    let executor = create_postgres_executor("sub_ephemeral_start_from_latest").await?;
    evento_test::subscription_ephemeral_start_from_latest(&executor).await
}

#[tokio::test]
async fn postgres_subscription_ephemeral_concurrent_same_key() -> anyhow::Result<()> {
    let executor = create_postgres_executor("sub_ephemeral_concurrent_same_key").await?;
    evento_test::subscription_ephemeral_concurrent_same_key(&executor).await
}

#[tokio::test]
async fn postgres_subscription_context_stop() -> anyhow::Result<()> {
    let executor = create_postgres_executor("sub_context_stop").await?;
    evento_test::subscription_context_stop(&executor).await
}

#[tokio::test]
async fn postgres_subscription_live() -> anyhow::Result<()> {
    let executor = create_postgres_executor("sub_live").await?;
    evento_test::subscription_live(&executor).await
}

#[tokio::test]
async fn postgres_subscription_ephemeral_run_once() -> anyhow::Result<()> {
    let executor = create_postgres_executor("sub_ephemeral_run_once").await?;
    evento_test::subscription_ephemeral_run_once(&executor).await
}