mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-07-04 04:17:10 +02:00
test create index
This commit is contained in:
parent
588add8bec
commit
72eed0e369
8 changed files with 689 additions and 0 deletions
27
tests/common/index.rs
Normal file
27
tests/common/index.rs
Normal file
|
@ -0,0 +1,27 @@
|
|||
use actix_web::http::StatusCode;
|
||||
use serde_json::{json, Value};
|
||||
|
||||
use super::service::Service;
|
||||
|
||||
pub struct Index<'a> {
|
||||
pub uid: String,
|
||||
pub service: &'a Service,
|
||||
}
|
||||
|
||||
impl Index<'_> {
|
||||
pub async fn get(&self) -> (Value, StatusCode) {
|
||||
let url = format!("/indexes/{}", self.uid);
|
||||
self.service.get(url).await
|
||||
}
|
||||
|
||||
pub async fn create<'a>(
|
||||
&'a self,
|
||||
primary_key: Option<&str>,
|
||||
) -> (Value, StatusCode) {
|
||||
let body = json!({
|
||||
"uid": self.uid,
|
||||
"primaryKey": primary_key,
|
||||
});
|
||||
self.service.post("/indexes", body).await
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue