rho-coding-agent 3.12.0

A fast Rust agent harness with a small footprint and opinionated defaults
Documentation
use std::collections::BTreeSet;

use pretty_assertions::assert_eq;
use rho_protocol::Device;

use super::devices;
use crate::app::daemon_http::tokens::DaemonTokenSet;

// Covers: the list shows each token as a device with what its record
// knows, last seen included, sorted by name, connected exactly when a
// bridged connection names it, and a token an earlier rho saved shows with
// nothing known.
// Owner: daemon_http::devices.
#[test]
fn the_list_shows_each_tokens_record() {
    let mut tokens: DaemonTokenSet = serde_json::from_value(serde_json::json!({
        "tokens": [{"name": "old-laptop", "sha256": "00"}]
    }))
    .unwrap();
    let phone = tokens.rotate_at("phone", 1_800_000_000).unwrap();
    tokens.set_platform("phone", Some("ios".to_owned()));
    tokens.mark_seen(phone.secret(), 1_800_000_090);
    tokens.rotate_at("desk", 1_700_000_000).unwrap();
    let connected = BTreeSet::from(["phone".to_owned()]);
    assert_eq!(
        devices(&tokens, &connected),
        [
            Device::new("desk").with_times(Some(1_700_000_000), None),
            Device::new("old-laptop"),
            Device::new("phone")
                .with_platform(Some("ios".to_owned()))
                .with_times(Some(1_800_000_000), Some(1_800_000_090))
                .connected(true),
        ]
    );
}