Cotton code
78 lines · 2.4 KB · RustRaw
use super::*;use cotton_store::file_identity::Namespace;const WORKSPACE: &str = "11111111-2222-3333-4444-555555555555";/// Node vectors (10) — five identities under two workspaces. The workspace is/// part of the material, so the same conversation in two files is two threads.#[test]fn whatsapp_thread_id_matches_node() {    let other = "99999999-8888-7777-6666-555555555555";    let vectors: [(&str, &str, &str); 10] = [        (            WORKSPACE,            "dm:919000000001",            "a9af0ec1-1101-5cc6-e6bc-0e5a24ded058",        ),        (            WORKSPACE,            "group:919000000009-1455852575@g.us",            "cf46c5bf-5bda-7313-cff8-5e768230efac",        ),        (            WORKSPACE,            "dm:15550001111",            "58931d2f-92ad-990f-b78a-048ac7208f0c",        ),        (            WORKSPACE,            "group:120363000000000000@g.us",            "ce42f42c-03cf-3a46-fa73-86ad86a203b4",        ),        (WORKSPACE, "dm:", "1beb7453-82cf-5342-5aae-242ff3b2d2b2"),        (            other,            "dm:919000000001",            "bc571410-4ea7-56a1-4a7f-b03d38945be0",        ),        (            other,            "group:919000000009-1455852575@g.us",            "12269544-b77c-e789-14b3-344ec3925b91",        ),        (            other,            "dm:15550001111",            "176141a3-23cb-0dad-5120-5363b49a4a0d",        ),        (            other,            "group:120363000000000000@g.us",            "01f5368f-e311-635b-1419-16ed97945961",        ),        (other, "dm:", "6181474a-c807-7f84-c6ae-bc52060708bc"),    ];    for (workspace, identity, expected) in vectors {        assert_eq!(            whatsapp_thread_id(&Namespace::for_tests(workspace), identity),            expected,            "whatsapp_thread_id({workspace}, {identity})"        );    }}/// Node vectors (4). The JID is the key, whole and unslugged — a title changes/// the day somebody renames the group, and this must not.#[test]fn whatsapp_group_key_matches_node() {    assert_eq!(        whatsapp_group_key("919000000009-1455852575@g.us"),        "wa:group:919000000009-1455852575@g.us"    );    assert_eq!(        whatsapp_group_key("120363000000000000@g.us"),        "wa:group:120363000000000000@g.us"    );    assert_eq!(whatsapp_group_key(""), "wa:group:");    assert_eq!(whatsapp_group_key("weird@g.us"), "wa:group:weird@g.us");}