Skip to content

Commit

Permalink
Increase coverage (#68)
Browse files Browse the repository at this point in the history
  • Loading branch information
Finomnis authored Oct 22, 2023
1 parent 374e241 commit 491ddcb
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions tests/integration_test_2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,3 +161,41 @@ async fn request_local_shutdown() {
.await
.unwrap();
}

#[cfg(unix)]
#[tokio::test]
#[traced_test]
async fn shutdown_through_signal_2() {
use nix::sys::signal::{self, Signal};
use nix::unistd::Pid;
use tokio_graceful_shutdown::FutureExt;

let subsystem = |subsys: SubsystemHandle| async move {
subsys.on_shutdown_requested().await;
sleep(Duration::from_millis(200)).await;
BoxedResult::Ok(())
};

tokio::join!(
async {
sleep(Duration::from_millis(100)).await;

// Send SIGINT to ourselves.
signal::kill(Pid::this(), Signal::SIGTERM).unwrap();
},
async {
let result = Toplevel::new(move |s| async move {
s.start(SubsystemBuilder::new("subsys", subsystem));
assert!(sleep(Duration::from_millis(1000))
.cancel_on_shutdown(&s)
.await
.is_err());
assert!(s.is_shutdown_requested());
})
.catch_signals()
.handle_shutdown_requests(Duration::from_millis(400))
.await;
assert!(result.is_ok());
},
);
}

0 comments on commit 491ddcb

Please sign in to comment.