//! The captured records `read`'s tests are checked against. //! //! `cmd::pr::read::fixtures`'s reasoning, one collection over: these are real //! bytes off real services, and the paragraphs saying what each capture holds //! are what let an assertion counting six rows in one be trusted. They live //! in a module of their own so there is one copy of those paragraphs rather //! than one per test that reads a file. //! //! Every capture below was taken from a service that has never heard of atgc, //! by an unauthenticated request anybody can repeat. What they are here to //! pin is the gap between the lexicon and the wild: `sh.tangled.repo.issue` //! types `repo` as a DID and marks `createdAt` required, and a live //! collection is full of records that do neither. Before these files, that //! was a claim four doc comments made and nothing checked. use serde_json::Value; /// `tangled.org/core`, which most of the captured issues are filed against /// and which every repo-scoped assertion here is scoped to. pub(super) const CORE_REPO: &str = "did:plc:j5hmlfdrwkvtxm7cjmu7j2is"; /// One page of one account's `sh.tangled.repo.issue` collection, which is /// exactly what `issue list` reads. /// /// Ten records, all of them issues on [`CORE_REPO`], and they do not agree /// about how to say so: six name it by DID, and four carry the pre-DID /// spelling — `repo` holding the at-uri of the repo *record*, with the repo's /// DID beside it in a `repoDid` property the lexicon has never had. Both /// stamp spellings are here too, `…Z` and `…+03:00`, which is why nothing in /// the listing compares `createdAt` as a string. /// /// ```text /// curl 'https://woodear.us-west.host.bsky.network/xrpc/com.atproto.repo.listRecords\ /// ?repo=did:plc:xasnlahkri4ewmbuzly2rlc5&collection=sh.tangled.repo.issue&limit=10\ /// &cursor=3mmbnhtrah522' /// ``` pub(super) const PDS_ISSUES: &str = include_str!(concat!( env!("CARGO_MANIFEST_DIR"), "/tests/fixtures/pds_issues_page.json" )); /// The index's answer about the same account, overlapping the page above. /// /// `sh.tangled.repo.listIssuesBy` wraps each record in the item envelope /// `merge_indexed` reads — `state` and `commentCount` beside the record — and /// it does not hand the record back untouched: a pre-DID record arrives with /// its `repo` rewritten to the repo DID and its own `repoDid` dropped, under /// the record's real CID. The two halves of a merged listing therefore /// disagree about the same issue, which is what `Listed` reading its fields /// off whichever row survived is for. /// /// ```text /// curl 'https://api.tangled.org/xrpc/sh.tangled.repo.listIssuesBy\ /// ?subject=did:plc:xasnlahkri4ewmbuzly2rlc5&limit=10&cursor=…' /// ``` pub(super) const BOBBIN_ISSUES: &str = include_str!(concat!( env!("CARGO_MANIFEST_DIR"), "/tests/fixtures/bobbin_list_issues_by.json" )); /// A single issue record in the shape every current writer produces: `repo` a /// DID, `createdAt` a UTC stamp, `mentions` and `references` present and /// empty. Captured with `com.atproto.repo.getRecord`, so it carries the /// `{uri, cid, value}` envelope `fetch_issue` reads. pub(super) const NEW_RECORD: &str = include_str!(concat!( env!("CARGO_MANIFEST_DIR"), "/tests/fixtures/issue_new_record.json" )); /// A single pre-DID record, and the densest one found in the wild: `repo` an /// at-uri, `createdAt` the empty string, and two properties no version of the /// lexicon has — `owner`, and `issueId` holding the appview's own issue /// number. The number being *in* a record is worth knowing, since `issue /// view 23` refuses on the grounds that it is nowhere; it is in this shape /// and in nothing written since. pub(super) const OLD_RECORD: &str = include_str!(concat!( env!("CARGO_MANIFEST_DIR"), "/tests/fixtures/issue_old_record.json" )); /// One account's whole `sh.tangled.repo.issue.state` collection: ten ordinary /// closes and two records that are neither dated nor pointed at anything — /// `createdAt` absent and `issue` the empty string, both of which the lexicon /// marks required. They are what `state_event` declines to read. pub(super) const STATES: &str = include_str!(concat!( env!("CARGO_MANIFEST_DIR"), "/tests/fixtures/issue_states.json" )); /// A second state collection, kept for one thing the first cannot show: live /// close/reopen/close chains, each three records inside seven seconds. The /// newest-wins rule has to settle those on the stamp and not on the order the /// PDS listed them in. pub(super) const STATES_REOPENED: &str = include_str!(concat!( env!("CARGO_MANIFEST_DIR"), "/tests/fixtures/issue_states_reopened.json" )); fn array(fixture: &str, key: &str) -> Vec { serde_json::from_str::(fixture).expect("fixture is JSON")[key] .as_array() .expect("fixture holds that array") .clone() } /// The `records` of a captured `listRecords` page. pub(super) fn records(fixture: &str) -> Vec { array(fixture, "records") } /// The `items` of a captured Bobbin listing. pub(super) fn items(fixture: &str) -> Vec { array(fixture, "items") } /// A captured `getRecord` response, whole. pub(super) fn single(fixture: &str) -> Value { serde_json::from_str(fixture).expect("fixture is JSON") }