change: Directly return tasks in wait test helpers
@@ -14,7 +14,7 @@ use super::{get_state, sleep_ms};
/// This is a small helper function, which checks in very short intervals, whether a task showed up
/// in the daemon or not.
-pub async fn wait_for_task(shared: &Shared, task_id: usize) -> Result<()> {
+pub async fn wait_for_task(shared: &Shared, task_id: usize) -> Result<Task> {
let tries = 20;
let mut current_try = 0;
while current_try <= tries {
@@ -25,7 +25,7 @@ pub async fn wait_for_task(shared: &Shared, task_id: usize) -> Result<()> {
continue;
}
- return Ok(());
+ return Ok(state.tasks.get(&task_id).unwrap().clone());
}
bail!("Task {} didn't show up in about 1 second.", task_id)
@@ -37,7 +37,7 @@ pub async fn wait_for_status_change(
shared: &Shared,
task_id: usize,
original_status: TaskStatus,
-) -> Result<()> {
+) -> Result<Task> {
let tries = 20;
let mut current_try = 0;
while current_try <= tries {
@@ -46,7 +46,7 @@ pub async fn wait_for_status_change(
Some(task) => {
// The status changed. We can give our ok!
if task.status != original_status {
- return Ok(());
+ return Ok(task.clone());
}
// The status didn't change. Try again.
@@ -65,7 +65,11 @@ pub async fn wait_for_status_change(
/// This is a small helper function, which checks in very short intervals, whether a task fulfills
/// a certain criteria. This is necessary to prevent long or potentially flaky timeouts in our tests.
-pub async fn wait_for_task_condition<F>(shared: &Shared, task_id: usize, condition: F) -> Result<()>
+pub async fn wait_for_task_condition<F>(
+ shared: &Shared,
+ task_id: usize,
+ condition: F,
+) -> Result<Task>
where
F: Fn(&Task) -> bool,
{
@@ -78,7 +82,7 @@ where
// Check if the condition is met.
// If it isn't, continue
if condition(task) {
- return Ok(());
+ return Ok(task.clone());
}
// The status didn't change to target. Try again.
