//! Integration smoke test for `cellos-export-s3`.
//!
//! Scope: smoke wires only — verifies `PresignedS3ExportSink` constructs from
//! a presigned-URL configuration, that `destination_hint` returns a logical
//! `s3://bucket/key` path, and that input validation rejects an invalid URL.

use cellos_core::ports::ExportSink;
use cellos_core::ExportReceiptTargetKind;
use cellos_export_s3::PresignedS3ExportSink;

#[test]
fn smoke_construct_presigned_sink_returns_s3_target() {
    let sink = PresignedS3ExportSink::new(
        "https://bucket.s3.amazonaws.com/object.txt?X-Amz-Signature=smoke",
        "smoke-cell",
        "smoke-bucket",
        Some("smoke/prefix".into()),
        Some("smoke-target".into()),
        Some("us-west-2".into()),
        1,
        0,
    )
    .expect("smoke: presigned URL must be accepted");

    assert_eq!(sink.target_kind(), Some(ExportReceiptTargetKind::S3));
    assert_eq!(
        sink.destination_hint("artifact.bin").expect("hint"),
        "s3://smoke-bucket/smoke/prefix/artifact.bin"
    );
}

#[test]
fn smoke_constructor_rejects_invalid_url() {
    let err = match PresignedS3ExportSink::new(
        "::not a url::",
        "smoke-cell",
        "smoke-bucket",
        None,
        None,
        None,
        1,
        0,
    ) {
        Ok(_) => panic!("smoke: malformed URL must be rejected"),
        Err(e) => e,
    };
    assert!(
        err.to_string().to_lowercase().contains("url")
            || err.to_string().to_lowercase().contains("scheme"),
        "expected URL-related error, got: {err}"
    );
}

#[test]
fn smoke_constructor_rejects_zero_attempts() {
    let err = match PresignedS3ExportSink::new(
        "https://bucket.s3.amazonaws.com/object",
        "smoke-cell",
        "smoke-bucket",
        None,
        None,
        None,
        0, // boundary: zero attempts must be rejected
        0,
    ) {
        Ok(_) => panic!("smoke: max_attempts==0 must be rejected"),
        Err(e) => e,
    };
    assert!(
        err.to_string().contains("max_attempts"),
        "expected max_attempts in error, got: {err}"
    );
}

// scope: smoke wires only; live S3 PUT happy path is covered by
// `supervisor_target_scoped_s3_export.rs` and `supervisor_github_oidc_s3_smoke.rs`.
