Library test: a sweep starts no more sessions than its bound

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-12-02 20:19:32 +01:00
commit 35085e6701

View file

@ -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.