// 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: batch use kreuzberg::BatchBytesItem; use kreuzberg::BatchFileItem; use kreuzberg::{batch_extract_bytes, batch_extract_bytes_sync, batch_extract_files, batch_extract_files_sync}; #[test] fn test_batch_bytes_invalid_mime() { // batch_extract_bytes_sync invalid MIME let items_json: serde_json::Value = serde_json::from_str(r#"[{"content":[72,101,108,108,111],"mime_type":"application/x-nonexistent"}]"#).unwrap(); let items = serde_json::from_value::>(items_json).unwrap(); let config = Default::default(); let _ = batch_extract_bytes_sync(items, &config).expect("should succeed"); } #[tokio::test] async fn test_batch_extract_bytes_happy() { // batch_extract_bytes: happy path with mixed inputs let items_json: serde_json::Value = serde_json::from_str(r#"[{"content":[72,101,108,108,111,44,32,119,111,114,108,100,33],"mime_type":"text/plain"},{"content":[60,104,116,109,108,62,60,98,111,100,121,62,84,101,115,116,60,47,98,111,100,121,62,60,47,104,116,109,108,62],"mime_type":"text/html"}]"#).unwrap(); let items = serde_json::from_value::>(items_json).unwrap(); let config = Default::default(); let result = batch_extract_bytes(items, &config).await.expect("should succeed"); assert!(!result.is_empty(), "expected >= 1"); } #[tokio::test] async fn test_batch_extract_bytes_mixed_format() { // batch_extract_bytes: handles unsupported MIME gracefully let items_json: serde_json::Value = serde_json::from_str( r#"[{"content":[80,68,70,32,112,108,97,99,101,104,111,108,100,101,114],"mime_type":"application/x-unknown"}]"#, ) .unwrap(); let items = serde_json::from_value::>(items_json).unwrap(); let config = Default::default(); let _ = batch_extract_bytes(items, &config).await.expect("should succeed"); } #[test] fn test_batch_extract_bytes_sync_empty_list() { // batch_extract_bytes_sync: empty batch let items_json: serde_json::Value = serde_json::from_str(r#"[]"#).unwrap(); let items = serde_json::from_value::>(items_json).unwrap(); let config = Default::default(); let result = batch_extract_bytes_sync(items, &config).expect("should succeed"); assert_eq!(result.len(), 0, "expected exactly 0 elements, got {}", result.len()); } #[test] fn test_batch_extract_bytes_sync_invalid_mime() { // batch_extract_bytes_sync: unsupported MIME let items_json: serde_json::Value = serde_json::from_str(r#"[{"content":[100,97,116,97],"mime_type":"application/x-unknown"}]"#).unwrap(); let items = serde_json::from_value::>(items_json).unwrap(); let config = Default::default(); let _ = batch_extract_bytes_sync(items, &config).expect("should succeed"); } #[tokio::test] async fn test_batch_file_async_basic() { // Extract text from multiple files asynchronously let paths_json: serde_json::Value = serde_json::from_str(r#"[{"path":"pdf/fake_memo.pdf"},{"path":"text/fake_text.txt"}]"#).unwrap(); let paths = serde_json::from_value::>(paths_json).unwrap(); let config = Default::default(); let _ = batch_extract_files(paths, &config).await.expect("should succeed"); } #[tokio::test] async fn test_batch_file_async_not_found() { // batch_extract_file async nonexistent let paths_json: serde_json::Value = serde_json::from_str(r#"[{"path":"/nonexistent/a.pdf"}]"#).unwrap(); let paths = serde_json::from_value::>(paths_json).unwrap(); let config = Default::default(); let _ = batch_extract_files(paths, &config).await.expect("should succeed"); } #[test] fn test_batch_file_not_found() { // batch_extract_file_sync nonexistent let paths_json: serde_json::Value = serde_json::from_str(r#"[{"path":"/nonexistent/a.pdf"},{"path":"/nonexistent/b.txt"}]"#).unwrap(); let paths = serde_json::from_value::>(paths_json).unwrap(); let config = Default::default(); let _ = batch_extract_files_sync(paths, &config).expect("should succeed"); } #[test] fn test_batch_file_partial() { // batch_extract_file_sync mixed let paths_json: serde_json::Value = serde_json::from_str(r#"[{"path":"text/plain.txt"},{"path":"/nonexistent/missing.pdf"}]"#).unwrap(); let paths = serde_json::from_value::>(paths_json).unwrap(); let config = Default::default(); let _ = batch_extract_files_sync(paths, &config).expect("should succeed"); } #[test] fn test_batch_file_sync_basic() { // Extract text from multiple files synchronously let paths_json: serde_json::Value = serde_json::from_str(r#"[{"path":"pdf/fake_memo.pdf"},{"path":"text/fake_text.txt"}]"#).unwrap(); let paths = serde_json::from_value::>(paths_json).unwrap(); let config = Default::default(); let _ = batch_extract_files_sync(paths, &config).expect("should succeed"); }