test delete documents

This commit is contained in:
mpostma 2021-02-22 16:03:17 +01:00
parent c95bf0cdf0
commit d3758b6f76
No known key found for this signature in database
GPG key ID: CBC8A7C1D7A28C3A
3 changed files with 85 additions and 2 deletions

View file

@ -68,7 +68,7 @@ impl Index<'_> {
self.service.put(url, documents).await
}
pub async fn wait_update_id(&self, update_id: u64) {
pub async fn wait_update_id(&self, update_id: u64) -> Value {
// try 10 times to get status, or panic to not wait forever
let url = format!("/indexes/{}/updates/{}", self.uid, update_id);
for _ in 0..10 {
@ -76,7 +76,7 @@ impl Index<'_> {
assert_eq!(status_code, 200);
if response["status"] == "processed" || response["status"] == "failed" {
return;
return response;
}
delay_for(Duration::from_secs(1)).await;
@ -116,6 +116,16 @@ impl Index<'_> {
self.service.get(url).await
}
pub async fn delete_document(&self, id: u64) -> (Value, StatusCode) {
let url = format!("/indexes/{}/documents/{}", self.uid, id);
self.service.delete(url).await
}
pub async fn clear_all_documents(&self) -> (Value, StatusCode) {
let url = format!("/indexes/{}/documents", self.uid);
self.service.delete(url).await
}
}
pub struct GetDocumentOptions;