fix the error messages and add tests

This commit is contained in:
Tamo
2022-11-14 23:18:04 +01:00
parent a8991ccb64
commit d08d97bf43
4 changed files with 146 additions and 17 deletions

View File

@ -110,13 +110,13 @@ impl Index<'_> {
self.service.get(url).await
}
pub async fn filtered_tasks(&self, type_: &[&str], status: &[&str]) -> (Value, StatusCode) {
pub async fn filtered_tasks(&self, types: &[&str], statuses: &[&str]) -> (Value, StatusCode) {
let mut url = format!("/tasks?indexUids={}", self.uid);
if !type_.is_empty() {
let _ = write!(url, "&types={}", type_.join(","));
if !types.is_empty() {
let _ = write!(url, "&types={}", types.join(","));
}
if !status.is_empty() {
let _ = write!(url, "&statuses={}", status.join(","));
if !statuses.is_empty() {
let _ = write!(url, "&statuses={}", statuses.join(","));
}
self.service.get(url).await
}

View File

@ -132,6 +132,10 @@ impl Server {
self.service.get("/tasks").await
}
pub async fn tasks_filter(&self, filter: Value) -> (Value, StatusCode) {
self.service.get(format!("/tasks?{}", yaup::to_string(&filter).unwrap())).await
}
pub async fn get_dump_status(&self, uid: &str) -> (Value, StatusCode) {
self.service.get(format!("/dumps/{}/status", uid)).await
}
@ -144,13 +148,13 @@ impl Server {
self.service.post("/swap-indexes", value).await
}
pub async fn cancel_task(&self, value: Value) -> (Value, StatusCode) {
pub async fn cancel_tasks(&self, value: Value) -> (Value, StatusCode) {
self.service
.post(format!("/tasks/cancel?{}", yaup::to_string(&value).unwrap()), json!(null))
.await
}
pub async fn delete_task(&self, value: Value) -> (Value, StatusCode) {
pub async fn delete_tasks(&self, value: Value) -> (Value, StatusCode) {
self.service.delete(format!("/tasks?{}", yaup::to_string(&value).unwrap())).await
}