fix(search): surface failed Meilisearch tasks; make ensure_index idempotent
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -50,3 +50,21 @@ async fn index_search_and_remove() {
|
||||
client.remove_object(vase).await.unwrap();
|
||||
assert!(client.search("wood").await.unwrap().is_empty());
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn ensure_index_is_idempotent() {
|
||||
let (url, key) = meili();
|
||||
let index = unique_index();
|
||||
let client = SearchClient::connect(&url, &key, &index).unwrap();
|
||||
client.ensure_index().await.unwrap();
|
||||
// second call against the now-existing index must succeed
|
||||
client.ensure_index().await.unwrap();
|
||||
|
||||
// and the client still works
|
||||
let id = domain::ObjectId::new();
|
||||
client
|
||||
.index_object(&doc(&id.to_string(), "lamp", &[]))
|
||||
.await
|
||||
.unwrap();
|
||||
assert_eq!(client.search("lamp").await.unwrap(), vec![id]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user