This commit is contained in:
71
e2e/dart/test/batch_test.dart
generated
Normal file
71
e2e/dart/test/batch_test.dart
generated
Normal file
@@ -0,0 +1,71 @@
|
||||
// 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 'package:kreuzberg/kreuzberg.dart';
|
||||
import 'package:kreuzberg/src/kreuzberg_bridge_generated/frb_generated.dart' show RustLib;
|
||||
import 'dart:convert';
|
||||
|
||||
// E2e tests for category: batch
|
||||
|
||||
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();
|
||||
});
|
||||
|
||||
test('Extract text from multiple files asynchronously', () async {
|
||||
final result = await KreuzbergBridge.batchExtractFiles([BatchFileItem(path: 'pdf/fake_memo.pdf'), BatchFileItem(path: 'text/fake_text.txt')]);
|
||||
});
|
||||
|
||||
test('batch_extract_file async nonexistent', () async {
|
||||
final result = await KreuzbergBridge.batchExtractFiles([BatchFileItem(path: '/nonexistent/a.pdf')]);
|
||||
});
|
||||
|
||||
test('batch_extract_file_sync nonexistent', () async {
|
||||
final result = await KreuzbergBridge.batchExtractFilesSync([BatchFileItem(path: '/nonexistent/a.pdf'), BatchFileItem(path: '/nonexistent/b.txt')]);
|
||||
});
|
||||
|
||||
test('batch_extract_file_sync mixed', () async {
|
||||
final result = await KreuzbergBridge.batchExtractFilesSync([BatchFileItem(path: 'text/plain.txt'), BatchFileItem(path: '/nonexistent/missing.pdf')]);
|
||||
});
|
||||
|
||||
test('Extract text from multiple files synchronously', () async {
|
||||
final result = await KreuzbergBridge.batchExtractFilesSync([BatchFileItem(path: 'pdf/fake_memo.pdf'), BatchFileItem(path: 'text/fake_text.txt')]);
|
||||
});
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user