Cotton code
43 lines · 2.7 KB · RustRaw
use super::*;fn row(id: &str, data: Value) -> Value {    json!({ "id": id, "data": data })}/// RULE (meetings-summaries, 17 Nov 2026): The Mac summarises a ready meeting with words that was never summarised, or was asked again since its last summary; one turned off, not ready, or with no lines is left, and a summary an assistant wrote is not overwritten unless asked again.#[test]fn the_mac_summarises_only_what_wants_it() {    let rows = vec![        row("new", json!({ "status": "ready", "lines": 12, "started_at": "2026-11-17T02:00:00Z" })),        row("old", json!({ "status": "ready", "lines": 12, "started_at": "2026-11-16T02:00:00Z" })),        row("done", json!({ "status": "ready", "lines": 12, "summarised_at": "2026-11-17T03:00:00Z", "summarised_by": "claude" })),        row("again", json!({ "status": "ready", "lines": 3, "started_at": "2026-11-17T05:00:00Z", "summarised_at": "2026-11-17T03:00:00Z", "summary_asked_at": "2026-11-17T04:00:00Z" })),        row("off", json!({ "status": "ready", "lines": 12, "summarise_on": "off" })),        row("waiting", json!({ "status": "waiting", "lines": 0 })),        row("silent", json!({ "status": "ready", "lines": 0 })),    ];    let wanted = wanting(&rows);    let ids: Vec<&str> = wanted.iter().map(|r| r["id"].as_str().unwrap()).collect();    assert_eq!(ids, ["old", "new", "again"]);}/// RULE (meetings-summaries, 17 Nov 2026): A meeting's day is the date it was held where it was held: started_at's own offset, not UTC's date; one written in UTC is read in the workspace's zone, and in UTC when the workspace names none — never the Mac's own zone.#[test]fn the_meetings_day_is_where_it_was_held() {    assert_eq!(meeting_day("2026-11-17T00:30:00+05:30", None), NaiveDate::from_ymd_opt(2026, 11, 17));    assert_eq!(meeting_day("2026-11-16T23:30:00-08:00", Some("Asia/Kolkata")), NaiveDate::from_ymd_opt(2026, 11, 16));    assert_eq!(meeting_day("2026-11-16T19:00:00Z", Some("Asia/Kolkata")), NaiveDate::from_ymd_opt(2026, 11, 17));    assert_eq!(meeting_day("2026-11-16T19:00:00Z", None), NaiveDate::from_ymd_opt(2026, 11, 16));    assert_eq!(meeting_day("not a time", None), None);}/// RULE (meetings-summaries, 17 Nov 2026): The summariser catalogue reads, names a default it holds, and every model in it has a file with a size and sha256 and somewhere to be fetched from.#[test]fn the_catalogue_names_its_default_and_where_each_model_comes_from() {    let c = catalogue();    assert!(c.models.contains_key(&c.default), "default {} is in the catalogue", c.default);    for (id, e) in &c.models {        assert!(e.file.bytes > 0 && e.file.sha256.len() == 64, "{id}");        assert!(e.file.url.is_some() || e.file.source.is_some(), "{id} can be fetched");    }}