Add test for SectionRunner pause/unpause
This commit is contained in:
parent
964c30b8b9
commit
42cce06d68
@ -487,4 +487,68 @@ mod test {
|
||||
runner.quit().await.unwrap();
|
||||
tokio::task::yield_now().await;
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_pause() {
|
||||
let (sections, interface) = make_sections_and_interface();
|
||||
let mut runner = SectionRunner::new(interface.clone());
|
||||
|
||||
let _run1 = runner
|
||||
.queue_run(sections[1].clone(), Duration::from_secs(10))
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let run2 = runner
|
||||
.queue_run(sections[0].clone(), Duration::from_secs(10))
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let _run3 = runner
|
||||
.queue_run(sections[1].clone(), Duration::from_secs(10))
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
pause();
|
||||
|
||||
advance(Duration::from_secs(1)).await;
|
||||
assert_section_states(&interface, &[false, true]);
|
||||
|
||||
runner.pause().await.unwrap();
|
||||
tokio::task::yield_now().await;
|
||||
assert_section_states(&interface, &[false, false]);
|
||||
|
||||
advance(Duration::from_secs(10)).await;
|
||||
assert_section_states(&interface, &[false, false]);
|
||||
|
||||
runner.unpause().await.unwrap();
|
||||
tokio::task::yield_now().await;
|
||||
assert_section_states(&interface, &[false, true]);
|
||||
|
||||
advance(Duration::from_secs(8)).await;
|
||||
assert_section_states(&interface, &[false, true]);
|
||||
|
||||
advance(Duration::from_secs(2)).await;
|
||||
assert_section_states(&interface, &[true, false]);
|
||||
|
||||
runner.pause().await.unwrap();
|
||||
tokio::task::yield_now().await;
|
||||
assert_section_states(&interface, &[false, false]);
|
||||
|
||||
// cancel paused run
|
||||
runner.cancel_run(run2).await.unwrap();
|
||||
tokio::task::yield_now().await;
|
||||
assert_section_states(&interface, &[false, false]);
|
||||
|
||||
runner.unpause().await.unwrap();
|
||||
tokio::task::yield_now().await;
|
||||
assert_section_states(&interface, &[false, true]);
|
||||
|
||||
advance(Duration::from_secs(10)).await;
|
||||
assert_section_states(&interface, &[false, false]);
|
||||
|
||||
resume();
|
||||
|
||||
runner.quit().await.unwrap();
|
||||
tokio::task::yield_now().await;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user