backbone-integrations 0.6.1

Integration registry: connectors, integration accounts and an idempotent inbound event lane, with one OAuth flow (HMAC-bound state, PKCE)
Documentation
//! IntegrationEvent API Integration Tests
//!
//! Generated by metaphor-schema. Do not edit manually.
//!
//! Tests the IntegrationEvent CRUD API endpoints.

use crate::integration::framework::ApiTest;
use serde_json::{json, Value};
use uuid::Uuid;

use super::crud_test_base::{CrudTestConfig, GenericCrudTest, TestDataGenerator};
use crate::integration::helpers::CommonUtils;

// ============================================================================
// INTEGRATIONEVENT TEST DATA GENERATOR
// ============================================================================

/// Test data generator for IntegrationEvent
pub struct IntegrationEventTestData;

impl TestDataGenerator for IntegrationEventTestData {
    fn generate_create_payload(&self, _utils: &CommonUtils) -> Value {
        json!({
            "id": Uuid::new_v4().to_string(),
            "connector_id": Uuid::new_v4().to_string(),
            "event_type": format!("Test {}", Uuid::new_v4().to_string().split('-').next().unwrap()),
            "external_id": format!("Test {}", Uuid::new_v4().to_string().split('-').next().unwrap()),
            "business_key": format!("Test {}", Uuid::new_v4().to_string().split('-').next().unwrap()),
            "status": "received",
            "payload": format!("Test {}", Uuid::new_v4().to_string().split('-').next().unwrap()),
            "mapped_ref_type": null,
            "mapped_ref_id": null,
            "error_detail": null,
            "metadata": json!({}),
        })
    }

    fn generate_update_payload(&self, id: &str, _utils: &CommonUtils) -> Value {
        json!({
            "id": id,
            "connector_id": Uuid::new_v4().to_string(),
            "event_type": format!("Test {}", Uuid::new_v4().to_string().split('-').next().unwrap()),
            "external_id": format!("Test {}", Uuid::new_v4().to_string().split('-').next().unwrap()),
            "business_key": format!("Test {}", Uuid::new_v4().to_string().split('-').next().unwrap()),
            "status": "received",
            "payload": format!("Test {}", Uuid::new_v4().to_string().split('-').next().unwrap()),
            "mapped_ref_type": null,
            "mapped_ref_id": null,
            "error_detail": null,
            "metadata": json!({}),
        })
    }

    fn generate_invalid_payload(&self) -> Value {
        json!({
            // Missing required fields
        })
    }

    async fn seed_dependencies(&self, api: &ApiTest) -> Vec<(String, String)> {
        let mut deps: Vec<(String, String)> = Vec::new();
        if let Some(id) = super::crud_test_base::create_and_get_id(api, "/api/v1/integration_connectors", &super::integration_connector_api_test::IntegrationConnectorTestData).await {
            deps.push(("connector_id".to_string(), id));
        }
        deps
    }
}

// ============================================================================
// INTEGRATIONEVENT API TEST
// ============================================================================

/// IntegrationEvent API test suite
pub struct IntegrationEventApiTest {
    inner: GenericCrudTest<IntegrationEventTestData>,
}

impl IntegrationEventApiTest {
    pub fn new() -> Self {
        let mut config = CrudTestConfig::new("/api/v1/integration_events", "IntegrationEvent");
        config.supports_soft_delete = true;
        Self {
            inner: GenericCrudTest::new(config, IntegrationEventTestData),
        }
    }

    pub async fn run_all(&mut self) -> Vec<crate::integration::framework::TestResult> {
        self.inner.run_all().await
    }
}

impl Default for IntegrationEventApiTest {
    fn default() -> Self {
        Self::new()
    }
}

// ============================================================================
// TESTS
// ============================================================================

#[cfg(test)]
mod tests {
    use super::*;

    #[tokio::test]
    async fn test_integration_event_crud() {
        let mut test = IntegrationEventApiTest::new();
        let results = test.run_all().await;

        for result in &results {
            println!("{:?}", result);
        }

        // Check all tests passed
        let failed: Vec<_> = results.iter().filter(|r| !r.success).collect();
        assert!(failed.is_empty(), "Some tests failed: {:?}", failed);
    }
}

// ============================================================================
// CUSTOM TESTS
// ============================================================================

// <<< CUSTOM TESTS START >>>
// Add IntegrationEvent specific tests here
// <<< CUSTOM TESTS END >>>