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:
2026-06-02 11:50:58 +02:00
parent dc903989f7
commit b8d198f150
2 changed files with 59 additions and 6 deletions
+18
View File
@@ -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]);
}