rho-coding-agent 3.12.0

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

use super::{placement, Placement};
use crate::daemon::login_session::LoginSession;

// Covers: on macOS a client outside the GUI login (an ssh login) must start
// the daemon in the GUI login through launchd while the user has one, or the
// daemon cannot use the login keychain; a client already in the GUI login,
// one with no GUI login to reach, and a platform without login sessions
// start it as a child of their own.
// Owner: daemon detach (macOS), which decides where a started daemon runs.
#[test]
fn only_a_client_outside_an_existing_gui_login_starts_the_daemon_through_launchd() {
    let gui = Some(LoginSession::Gui);
    let background = Some(LoginSession::Background);
    for (case, client, gui_login, expected) in [
        (
            "ssh login, user at the screen",
            background,
            true,
            Placement::LaunchAgent,
        ),
        (
            "ssh login, nobody at the screen",
            background,
            false,
            Placement::ClientSession,
        ),
        (
            "terminal in the GUI login",
            gui,
            true,
            Placement::ClientSession,
        ),
        (
            "no login sessions (Linux)",
            None,
            false,
            Placement::ClientSession,
        ),
    ] {
        assert_eq!(placement(client, || gui_login), expected, "{case}");
    }
}