add tests on the index resource

This commit is contained in:
Tamo
2023-01-24 13:20:20 +01:00
parent e664f09045
commit 32364e9919
4 changed files with 279 additions and 0 deletions

View File

@ -63,6 +63,11 @@ impl Index<'_> {
self.service.post_encoded("/indexes", body, self.encoder).await
}
pub async fn update_raw(&self, body: Value) -> (Value, StatusCode) {
let url = format!("/indexes/{}", urlencode(self.uid.as_ref()));
self.service.patch_encoded(url, body, self.encoder).await
}
pub async fn update(&self, primary_key: Option<&str>) -> (Value, StatusCode) {
let body = json!({
"primaryKey": primary_key,

View File

@ -95,10 +95,18 @@ impl Server {
self.index_with_encoder(uid, Encoder::Plain)
}
pub async fn create_index(&self, body: Value) -> (Value, StatusCode) {
self.service.post("/indexes", body).await
}
pub fn index_with_encoder(&self, uid: impl AsRef<str>, encoder: Encoder) -> Index<'_> {
Index { uid: uid.as_ref().to_string(), service: &self.service, encoder }
}
pub async fn list_indexes_raw(&self, parameters: &str) -> (Value, StatusCode) {
self.service.get(format!("/indexes{parameters}")).await
}
pub async fn list_indexes(
&self,
offset: Option<usize>,