test create index

This commit is contained in:
mpostma 2021-02-18 19:50:52 +01:00
parent 588add8bec
commit 72eed0e369
No known key found for this signature in database
GPG key ID: CBC8A7C1D7A28C3A
8 changed files with 689 additions and 0 deletions

27
tests/common/index.rs Normal file
View 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
}
}