use monk_sdk::validation::{validate_batch, validate_event};
use monk_sdk::{Event, MonkError};

#[test]
fn validate_event_accepts_customer_id_or_external_customer_id() {
    let with_customer = Event::builder()
        .customer_id("cust_123")
        .event_name("api_call")
        .build()
        .expect("valid event");
    validate_event(&with_customer).expect("event with customer_id should be valid");

    let with_external = Event::builder()
        .external_customer_id("ext_123")
        .event_name("api_call")
        .build()
        .expect("valid event");
    validate_event(&with_external).expect("event with external_customer_id should be valid");
}

#[test]
fn validate_event_rejects_missing_customer_identity() {
    let event = Event::builder()
        .event_name("api_call")
        .build()
        .expect("builder only enforces event_name");

    let err = validate_event(&event).expect_err("identity is required");
    match err {
        MonkError::Validation(msg) => {
            assert!(msg.contains("exactly one of customerId or externalCustomerId is required"))
        }
        other => panic!("unexpected error variant: {other}"),
    }
}

#[test]
fn validate_batch_rejects_empty_batch() {
    let err = validate_batch(&[]).expect_err("empty batches must be rejected");
    match err {
        MonkError::Validation(msg) => assert!(msg.contains("must not be empty")),
        other => panic!("unexpected error variant: {other}"),
    }
}
