test index update

This commit is contained in:
mpostma
2021-02-18 20:28:10 +01:00
parent 68692a256e
commit 4c5effe714
5 changed files with 29 additions and 20 deletions

View File

@ -35,5 +35,21 @@ impl Service {
let response = serde_json::from_slice(&body).unwrap_or_default();
(response, status_code)
}
pub async fn put(&self, url: impl AsRef<str>, body: Value) -> (Value, StatusCode) {
let mut app =
test::init_service(meilisearch_http::create_app(&self.0, true).wrap(NormalizePath)).await;
let req = test::TestRequest::put()
.uri(url.as_ref())
.set_json(&body)
.to_request();
let res = test::call_service(&mut app, req).await;
let status_code = res.status();
let body = test::read_body(res).await;
let response = serde_json::from_slice(&body).unwrap_or_default();
(response, status_code)
}
}