Files
fil/e2e/rust/tests/embed_async_pending_test.rs

40 lines
1.8 KiB
Rust
Raw Normal View History

2026-06-01 23:40:55 +02:00
// 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: embed_async_pending
use kreuzberg::embed_texts_async;
#[tokio::test]
async fn test_embed_texts_async_empty_input() {
// embed_texts_async: empty text list
let texts_json: serde_json::Value = serde_json::from_str(r#"[]"#).unwrap();
let texts = serde_json::from_value::<Vec<String>>(texts_json).unwrap();
let config = Default::default();
let result = embed_texts_async(texts, &config).await.expect("should succeed");
assert_eq!(result.len(), 0, "expected exactly 0 elements, got {}", result.len());
}
#[tokio::test]
async fn test_embed_texts_async_happy() {
// embed_texts_async: basic async embedding
let texts_json: serde_json::Value = serde_json::from_str(r#"["First","Second"]"#).unwrap();
let texts = serde_json::from_value::<Vec<String>>(texts_json).unwrap();
let config = Default::default();
let result = embed_texts_async(texts, &config).await.expect("should succeed");
assert!(result.len() >= 2, "expected at least 2 elements, got {}", result.len());
}
#[tokio::test]
async fn test_embed_texts_async_preset_switch() {
// embed_texts_async: preset override
let texts_json: serde_json::Value = serde_json::from_str(r#"["Text"]"#).unwrap();
let texts = serde_json::from_value::<Vec<String>>(texts_json).unwrap();
let config_json: serde_json::Value =
serde_json::from_str(r#"{"model":{"name":"balanced","type":"preset"}}"#).unwrap();
let config = serde_json::from_value(config_json).unwrap();
let _ = embed_texts_async(texts, &config).await.expect("should succeed");
}