Cotton code
59 lines · 3.5 KB · SwiftRaw
// A code host's connection — the pure half of the Code hosting sheet, kept// word for word by the Connected table (`CodeHostFacts`): the token line and// the name and service the worker looks the sealed row up by, the questions// Remove and Push to Cotton ask, when Push to Cotton is offered, and the bytes// line the repository page shares. What the sheet DID — sealing a token// (create or update, the vault opened once), binning it, holding a repository,// pushing it to Cotton — is the Connected page's columns and acts now, and// `ConnectedActionsTests` drives them through the source.//// Every fixture is synthetic: `git.example.org` is the reserved example domain.import CottonKitimport XCTest@testable import CottonUI@MainActorfinal class CodeHostFactsTests: XCTestCase {    // ── the read ──────────────────────────────────────────────────────────    // ── saving one ────────────────────────────────────────────────────────    // ── the vault ─────────────────────────────────────────────────────────    // ── removing one ──────────────────────────────────────────────────────    // ── holding a repository ──────────────────────────────────────────────    // ── the sentences ─────────────────────────────────────────────────────    // ── the clone URL, and where the pushes go ────────────────────────────    /// A read whose repositories carry the three columns **Push to Cotton** and    /// the clone URL are drawn from. Its own fixture rather than a fourth    /// column on the shared one: the Hold tests press a verb on `r-1`    /// precisely because Cotton does NOT hold it.    private static let heldAnswer = """        {"hosts":[          {"host":"git.example.org","kind":"forgejo",           "repos":[             {"id":"r-1","label":"nobody/gadget","syncState":"ok","lastError":null,              "syncedAt":"2026-09-15T09:26:00.000Z","held":true,"origin":"forgejo",              "bundleState":"ok","bundledAt":"2026-09-15T09:26:00.000Z",              "cloneUrl":"https://studio.relay.cottondb.com/git/nobody/gadget.git"},             {"id":"r-2","label":"nobody/bundling","syncState":"ok","lastError":null,              "syncedAt":null,"held":true,"origin":"forgejo","bundleState":"bundling",              "cloneUrl":"https://studio.relay.cottondb.com/git/nobody/bundling.git"},             {"id":"r-3","label":"nobody/ours","syncState":"ok","lastError":null,              "syncedAt":null,"held":true,"origin":"cotton","bundleState":"ok",              "cloneUrl":"https://studio.relay.cottondb.com/git/nobody/ours.git"},             {"id":"r-4","label":"nobody/watched","syncState":"ok","lastError":null,              "syncedAt":null,"held":false,"origin":"forgejo","bundleState":null,              "cloneUrl":null}           ],           "token":{"set":true,"hint":"9zx4","secretId":"s-1"}}        ]}        """}