use std::{
error::Error,
io,
sync::Arc,
};
use qubit_executor::service::RejectedExecution;
#[test]
fn test_rejected_execution_variants_display_and_compare() {
assert_eq!(
RejectedExecution::Shutdown.to_string(),
"task rejected because the executor service is shut down",
);
assert_eq!(
RejectedExecution::Saturated.to_string(),
"task rejected because the executor service is saturated",
);
let first = RejectedExecution::WorkerSpawnFailed {
source: Arc::new(io::Error::other("first")),
};
let second = RejectedExecution::WorkerSpawnFailed {
source: Arc::new(io::Error::other("second")),
};
assert_eq!(first, second);
assert_ne!(first, RejectedExecution::Shutdown);
assert_eq!(
first
.source()
.expect("worker spawn failure should expose source")
.to_string(),
"first",
);
}