yog 0.0.2

yog: a balls-oriented session manager for lernie loops (egui frontend)
Documentation
//! The §8.5 search reply's own encoding: three address shapes flattened onto
//! the keys the gestures already take, and the unreadable half beside the rows.

use super::*;

#[test]
fn a_search_reply_flattens_each_address_and_names_what_it_could_not_read() {
    use crate::search::{Address, Field, Found, Hit};
    let hit = |at, field| Hit {
        at,
        field,
        offset: 7,
        excerpt: "…tekeli-li…".to_owned(),
    };
    let value = encode(&Reply::Search(Found {
        hits: vec![
            hit(
                Address::Ball {
                    project: PathBuf::from("/proj"),
                    id: "bl-1f2a".to_owned(),
                },
                Field::Name,
            ),
            hit(
                Address::Workspace {
                    path: PathBuf::from("/names/alba"),
                },
                Field::Summary,
            ),
            hit(
                Address::Conversation {
                    workspace: PathBuf::from("/names/alba"),
                    agent: "c-1".to_owned(),
                },
                Field::Text,
            ),
        ],
        unreadable: vec!["/gone: balls unlistable".to_owned()],
    }));
    assert_eq!(value["kind"], "search");
    let rows = value["rows"].as_array().expect("rows");
    assert_eq!(rows[0]["at"], "ball");
    assert_eq!(rows[0]["project"], "/proj");
    assert_eq!(rows[0]["id"], "bl-1f2a");
    assert_eq!(rows[0]["field"], "name");
    assert_eq!(rows[0]["offset"], 7);
    assert_eq!(rows[0]["excerpt"], "…tekeli-li…");
    assert_eq!(rows[1]["at"], "workspace");
    assert_eq!(rows[1]["workspace"], "/names/alba");
    assert_eq!(rows[1]["field"], "summary");
    assert_eq!(rows[2]["at"], "conversation");
    assert_eq!(rows[2]["agent"], "c-1");
    assert_eq!(rows[2]["field"], "text");
    assert_eq!(value["unreadable"][0], "/gone: balls unlistable");
}