Skip to content

Commit

Permalink
Increase coverage of alive_guard
Browse files Browse the repository at this point in the history
  • Loading branch information
Finomnis committed Oct 20, 2023
1 parent 7f8125d commit 2e0e050
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/runner/alive_guard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,12 @@ impl Drop for Inner {
mod tests {

use std::sync::atomic::{AtomicU32, Ordering};
use tracing_test::traced_test;

use super::*;

#[test]
#[traced_test]
fn finished_callback() {
let alive_guard = AliveGuard::new();

Expand All @@ -82,6 +84,7 @@ mod tests {
}

#[test]
#[traced_test]
fn cancel_callback() {
let alive_guard = AliveGuard::new();

Expand All @@ -99,6 +102,7 @@ mod tests {
}

#[test]
#[traced_test]
fn both_callbacks() {
let alive_guard = AliveGuard::new();

Expand All @@ -117,4 +121,13 @@ mod tests {

assert_eq!(counter.load(Ordering::Relaxed), 2);
}

#[test]
#[traced_test]
fn no_callback() {
let alive_guard = AliveGuard::new();
drop(alive_guard);

assert!(logs_contain("No `finished` callback was registered in AliveGuard! This should not happen, please report this at https://github.com/Finomnis/tokio-graceful-shutdown/issues."));
}
}

0 comments on commit 2e0e050

Please sign in to comment.