This commit is contained in:
21
docs/snippets/elixir/plugins/plugin_testing.md
Normal file
21
docs/snippets/elixir/plugins/plugin_testing.md
Normal file
@@ -0,0 +1,21 @@
|
||||
<!-- snippet:skip reason="Elixir Rustler NIFs cannot host async Send + Sync + 'static Rust trait objects via callbacks; the BEAM actor-model boundary requires plugin work to live in the Rust core. The alef-generated Elixir trait_call macro additionally has a backslash/encoding bug (separate alef-codegen ticket). Custom plugins must be implemented in Rust." -->
|
||||
Plugin testing in Elixir is limited since custom plugins cannot be implemented in Elixir. Plugin testing should be done in Rust using `#[cfg(test)]` test modules.
|
||||
|
||||
When testing custom plugins in Rust:
|
||||
|
||||
```rust
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_custom_extractor() {
|
||||
let extractor = MyExtractor;
|
||||
let content = b"test content";
|
||||
let result = extractor.extract_bytes(content, "text/plain", &ExtractionConfig::default()).await;
|
||||
assert!(result.is_ok());
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
For Elixir, you can test the extraction results using the built-in functions like `Kreuzberg.extract_bytes_async/3` and `Kreuzberg.extract_file_async/3`.
|
||||
Reference in New Issue
Block a user