rho-coding-agent 3.11.0

A fast Rust agent harness with a small footprint and opinionated defaults
Documentation
use pretty_assertions::assert_eq;

use super::{Ending, Shutdown};

// Covers: when two requests end the daemon, the ending its clients are told
// and the process follows: a stop wins over a restart and a replacement, so
// no client hears it may start a daemon the user stopped, and a replacement
// wins over a restart (#1995).
// Owner: daemon shutdown.
#[test]
fn a_later_request_changes_the_ending_only_as_far_as_the_rule_lets_it() {
    use Ending::{Replace, Restart, Stop};
    let cases = [
        (Restart, Stop, Stop),
        (Stop, Restart, Stop),
        (Stop, Replace, Stop),
        (Replace, Stop, Stop),
        (Restart, Replace, Replace),
        (Replace, Restart, Replace),
    ];
    for (first, then, decided) in cases {
        let shutdown = Shutdown::default();
        shutdown.request(first, |_| {});
        let mut prepared = None;
        shutdown.request(then, |ending| prepared = Some(ending));
        assert_eq!(
            (shutdown.ending(), prepared),
            (decided, Some(decided)),
            "{first:?} then {then:?}"
        );
    }
}