Skip to content

Commit

Permalink
Add another test for cancellation token
Browse files Browse the repository at this point in the history
  • Loading branch information
Finomnis committed Nov 21, 2023
1 parent a022ecd commit 69a9a2c
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tests/integration_test_2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,3 +225,25 @@ async fn cancellation_token() {
.await;
assert!(result.is_ok());
}

#[tokio::test]
#[traced_test]
async fn cancellation_token_does_not_propagate_up() {
let subsystem = |subsys: SubsystemHandle| async move {
let cancellation_token = subsys.create_cancellation_token();

cancellation_token.cancel();
assert!(!subsys.is_shutdown_requested());

BoxedResult::Ok(())
};

let toplevel = Toplevel::new(move |s| async move {
s.start(SubsystemBuilder::new("subsys", subsystem));
});

let result = toplevel
.handle_shutdown_requests(Duration::from_millis(400))
.await;
assert!(result.is_ok());
}

0 comments on commit 69a9a2c

Please sign in to comment.