klieo-workflow-api 3.8.2

Embeddable Axum run-service router fronting klieo-workflow (submit / poll declarative workflows).
Documentation
//! Router-assembly tests: required ports gate `build()`.

mod common;

use klieo_bus_memory::MemoryBus;
use klieo_workflow_api::{RunStore, WorkflowRunBuilderError, WorkflowRunRouterBuilder};

#[tokio::test]
async fn build_with_all_ports_succeeds() {
    let router = WorkflowRunRouterBuilder::new()
        .with_authenticator(common::test_authenticator())
        .with_app(common::test_app().await)
        .with_registry(common::test_registry())
        .with_run_store(RunStore::new(MemoryBus::new().kv))
        .with_provenance(common::test_provenance())
        .build();
    assert!(router.is_ok(), "all ports configured must build a router");
}

#[tokio::test]
async fn build_without_provenance_reports_missing_provenance() {
    let result = WorkflowRunRouterBuilder::new()
        .with_authenticator(common::test_authenticator())
        .with_app(common::test_app().await)
        .with_registry(common::test_registry())
        .with_run_store(RunStore::new(MemoryBus::new().kv))
        .build();
    assert!(matches!(
        result,
        Err(WorkflowRunBuilderError::MissingProvenance)
    ));
}

#[tokio::test]
async fn build_without_app_reports_missing_app() {
    let result = WorkflowRunRouterBuilder::new()
        .with_authenticator(common::test_authenticator())
        .build();
    assert!(matches!(result, Err(WorkflowRunBuilderError::MissingApp)));
}

#[tokio::test]
async fn build_without_registry_reports_missing_registry() {
    let result = WorkflowRunRouterBuilder::new()
        .with_authenticator(common::test_authenticator())
        .with_app(common::test_app().await)
        .build();
    assert!(matches!(
        result,
        Err(WorkflowRunBuilderError::MissingRegistry)
    ));
}

#[tokio::test]
async fn build_without_run_store_reports_missing_run_store() {
    let result = WorkflowRunRouterBuilder::new()
        .with_authenticator(common::test_authenticator())
        .with_app(common::test_app().await)
        .with_registry(common::test_registry())
        .build();
    assert!(matches!(
        result,
        Err(WorkflowRunBuilderError::MissingRunStore)
    ));
}