use std::time::Duration;
use pretty_assertions::assert_eq;
use super::wait_until_gone;
// Covers: a stop returns only once the manager let go of the service (here
// on the third look), and one that never does fails after the timeout
// instead of hanging, naming how long it waited.
// Owner: service manager stop (pure polling).
#[test]
fn a_stop_waits_until_the_service_is_gone_within_its_timeout() {
let mut looks = 0;
let gone_on_third = wait_until_gone(
|| {
looks += 1;
looks == 3
},
Duration::from_secs(60),
Duration::ZERO,
);
assert_eq!((gone_on_third, looks), (Ok(()), 3));
let never = wait_until_gone(|| false, Duration::ZERO, Duration::ZERO);
assert!(never.is_err());
}