// 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 // ignore_for_file: unused_local_variable import 'package:test/test.dart'; import 'dart:io'; import 'package:kreuzberg/kreuzberg.dart'; import 'package:kreuzberg/src/kreuzberg_bridge_generated/frb_generated.dart' show RustLib; // E2e tests for category: error String _alefE2eText(Object? value) { if (value == null) return ''; // Check if it's an enum by examining its toString representation. final str = value.toString(); if (str.contains('.')) { // Enum.toString() returns 'EnumName.variantName'. Extract the variant name. final parts = str.split('.'); if (parts.length == 2) { final variantName = parts[1]; // Convert camelCase variant names to snake_case for serde compatibility. // E.g. 'toolCalls' -> 'tool_calls', 'stop' -> 'stop'. return _camelToSnake(variantName); } } return str; } String _camelToSnake(String camel) { final buffer = StringBuffer(); for (int i = 0; i < camel.length; i++) { final char = camel[i]; if (char.contains(RegExp(r'[A-Z]'))) { if (i > 0) buffer.write('_'); buffer.write(char.toLowerCase()); } else { buffer.write(char); } } return buffer.toString(); } void main() { setUpAll(() async { await RustLib.init(); final _testDocs = Platform.environment['FIXTURES_DIR'] ?? '../../test_documents'; final _dir = Directory(_testDocs); if (_dir.existsSync()) Directory.current = _dir; }); test('Graceful handling of empty bytes (should not error)', () async { final result = await KreuzbergBridge.extractBytesSync(File('text/empty.txt').readAsBytesSync(), 'text/plain'); }); test('Error when extracting with empty MIME type', () async { await expectLater(KreuzbergBridge.extractBytesSync(File('text/plain.txt').readAsBytesSync(), ''), throwsA(anything)); }); test('extract_bytes force+disable OCR', () async { await expectLater(KreuzbergBridge.extractBytesSync(File('text/fake_text.txt').readAsBytesSync(), 'text/plain', ExtractionConfig(useCache: true, enableQualityProcessing: true, forceOcr: true, disableOcr: true, resultFormat: ResultFormat.unified, outputFormat: OutputFormat.plain(), includeDocumentStructure: false, useLayoutForMarkdown: false, maxArchiveDepth: 3)), throwsA(anything)); }); test('Error when extracting with invalid MIME type format', () async { await expectLater(KreuzbergBridge.extractBytesSync(File('text/plain.txt').readAsBytesSync(), 'not-a-mime'), throwsA(anything)); }); test('Error when extracting with unsupported MIME type', () async { await expectLater(KreuzbergBridge.extractBytesSync(File('text/plain.txt').readAsBytesSync(), 'application/x-nonexistent'), throwsA(anything)); }); }