// This file is auto-generated by alef — DO NOT EDIT.
// alef:hash:4e15143f4af1ae8bafbdb1506ef057da924484c66a19483966333558ad437e75
// To regenerate: alef generate
// To verify freshness: alef verify --exit-code
// Issues & docs: https://github.com/kreuzberg-dev/alef
//! E2e tests for category: async

use kreuzberg::extract_bytes;

#[tokio::test]
async fn test_async_extract_bytes() {
    // Async extract_bytes call on PDF document
    let content = std::fs::read(concat!(
        env!("CARGO_MANIFEST_DIR"),
        "/../../test_documents/pdf/fake_memo.pdf"
    ))
    .expect("test_documents/pdf/fake_memo.pdf must exist");
    let mime_type = r#"application/pdf"#;
    let config = Default::default();
    let result = extract_bytes(&content, mime_type, &config)
        .await
        .expect("should succeed");
    assert_eq!(
        result.mime_type.to_string().as_str().trim(),
        r#"application/pdf"#,
        "equals assertion failed"
    );
    assert!(
        result.content.len() >= 50,
        "expected length >= 50, got {}",
        result.content.len()
    );
}

#[tokio::test]
async fn test_async_extract_bytes_empty_mime() {
    // extract_bytes empty MIME async
    let content = std::fs::read(concat!(
        env!("CARGO_MANIFEST_DIR"),
        "/../../test_documents/text/plain.txt"
    ))
    .expect("test_documents/text/plain.txt must exist");
    let mime_type = r#""#;
    let config_json: serde_json::Value = serde_json::from_str(r#"{}"#).unwrap();
    let config = serde_json::from_value(config_json).unwrap();
    let result = extract_bytes(&content, mime_type, &config).await;
    assert!(result.is_err(), "expected call to fail");
}

#[tokio::test]
async fn test_async_extract_bytes_invalid_mime() {
    // extract_bytes unsupported MIME async
    let content = std::fs::read(concat!(
        env!("CARGO_MANIFEST_DIR"),
        "/../../test_documents/text/plain.txt"
    ))
    .expect("test_documents/text/plain.txt must exist");
    let mime_type = r#"application/x-nonexistent"#;
    let config_json: serde_json::Value = serde_json::from_str(r#"{}"#).unwrap();
    let config = serde_json::from_value(config_json).unwrap();
    let result = extract_bytes(&content, mime_type, &config).await;
    assert!(result.is_err(), "expected call to fail");
}
