()
| 392 | |
| 393 | #[tokio::test] |
| 394 | async fn test_worker_pool_shutdown() { |
| 395 | let pool = WorkerPool::new(2); |
| 396 | |
| 397 | // Submit some jobs |
| 398 | let mut submitted = 0; |
| 399 | let mut attempts = 0; |
| 400 | while submitted < 3 && attempts < 100 { |
| 401 | let job = TestJob { |
| 402 | id: format!("job-{}", submitted), |
| 403 | duration_ms: 50, |
| 404 | should_fail: false, |
| 405 | }; |
| 406 | if pool.try_submit(job).await.unwrap().is_some() { |
| 407 | submitted += 1; |
| 408 | } else { |
| 409 | // Wait a bit for a worker to become available |
| 410 | sleep(Duration::from_millis(10)).await; |
| 411 | } |
| 412 | attempts += 1; |
| 413 | } |
| 414 | assert_eq!(submitted, 3, "Should have submitted all 3 jobs"); |
| 415 | |
| 416 | // Shutdown the pool |
| 417 | let results = pool.shutdown().await.unwrap(); |
| 418 | |
| 419 | // Should get results for all submitted jobs |
| 420 | assert_eq!( |
| 421 | results.len(), |
| 422 | 3, |
| 423 | "Should get results for all 3 submitted jobs" |
| 424 | ); |
| 425 | |
| 426 | // Pool should now reject new submissions |
| 427 | let job = TestJob { |
| 428 | id: "late-job".to_string(), |
| 429 | duration_ms: 10, |
| 430 | should_fail: false, |
| 431 | }; |
| 432 | |
| 433 | let result = pool.try_submit(job).await; |
| 434 | assert!(result.is_err()); |
| 435 | let err = result.err().unwrap(); |
| 436 | assert!(err.message.contains("shutting down")); |
| 437 | } |
| 438 | |
| 439 | #[tokio::test] |
| 440 | async fn test_worker_pool_worker_counts() { |
nothing calls this directly
no test coverage detected