diff --git a/crates/ghostlight/src/controllers.rs b/crates/ghostlight/src/controllers.rs index db8931a..d2ece24 100644 --- a/crates/ghostlight/src/controllers.rs +++ b/crates/ghostlight/src/controllers.rs @@ -14308,6 +14308,31 @@ mod tests { task.await.unwrap(); } + /// The caller's session bound: two entries and a pool that could run both, + /// but a sweep asked for one session starts one, and the next sweep answers + /// the other. + #[tokio::test] + async fn a_sweep_starts_no_more_sessions_than_it_was_given() { + let (_directory, mailbox, task, _commons, roads) = dead_end_world( + crate::tests::stock_weights(), + &["The Unwalked Road", "The Far Road"], + Roots::Commons, + 0, + ) + .await; + let port = Arc::new(SweepPort::new(shed_on_the_named_road(vec![ + ("The Unwalked Road", roads[0]), + ("The Far Road", roads[1]), + ]))); + let runner = sweep_runner(&mailbox, port.clone(), fresh_store()); + runner.sweep(pool(2), 1).await.unwrap(); + assert_eq!(port.calls(), 1, "a bound of one started more than one session"); + runner.sweep(pool(2), 1).await.unwrap(); + assert_eq!(port.calls(), 2, "the second sweep answers the entry the first left"); + drop(mailbox); + task.await.unwrap(); + } + /// The same two entries under a pool of one: the first session is held /// inside the provider boundary with no permit free, and the second starts /// only after the first has finished.