// 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 // swift-format-ignore-file import XCTest import Foundation #if canImport(FoundationNetworking) import FoundationNetworking #endif import Kreuzberg import RustBridge /// E2e tests for category: error. final class ErrorTests: XCTestCase { override class func setUp() { super.setUp() let _testDocs = URL(fileURLWithPath: #filePath) .deletingLastPathComponent() // Tests/ .deletingLastPathComponent() // Tests/ .deletingLastPathComponent() // swift/ .deletingLastPathComponent() // packages/ .deletingLastPathComponent() // .appendingPathComponent("test_documents") if FileManager.default.fileExists(atPath: _testDocs.path) { FileManager.default.changeCurrentDirectoryPath(_testDocs.path) } } func testErrorEmptyBytes() throws { // Graceful handling of empty bytes (should not error) let result = try Kreuzberg.extractBytesSync("text/empty.txt", "text/plain", "{}") } func testErrorEmptyMime() throws { // Error when extracting with empty MIME type do { _ = try Kreuzberg.extractBytesSync("text/plain.txt", "", "{}") XCTFail("expected to throw") } catch { // success } } func testErrorExtractBytesConflictingOcr() throws { // extract_bytes force+disable OCR do { _ = try Kreuzberg.extractBytesSync("text/fake_text.txt", "text/plain", "{\"disable_ocr\":true,\"force_ocr\":true}") XCTFail("expected to throw") } catch { // success } } func testErrorInvalidMimeFormat() throws { // Error when extracting with invalid MIME type format do { _ = try Kreuzberg.extractBytesSync("text/plain.txt", "not-a-mime", "{}") XCTFail("expected to throw") } catch { // success } } func testErrorUnsupportedMime() throws { // Error when extracting with unsupported MIME type do { _ = try Kreuzberg.extractBytesSync("text/plain.txt", "application/x-nonexistent", "{}") XCTFail("expected to throw") } catch { // success } } }