oficina / equipo Public

Clone
git clone https://amadan.net/oficina/equipo

Plain git — no account needed to clone.

Download

Download this file

1import Foundation
2import Testing
3@testable import EquipoKit
4
5@MainActor @Suite struct SignInLifetimeTests {
6 @Test func endedOrForeignLifetimesCannotPersistAnything() throws {
7 let store = MemorySecretStore()
8 let accounts = DeviceAccounts(store: store)
9 let old = accounts.lifetimes.current
10 var account = DeviceAccount.new(origin: URL(string: "https://example.test")!, label: "Test")
11 account.credential = try Fixture.decode("device-credential")
12 try accounts.commit(.save(account), lifetime: old)
13 old.end()
14 let before = store.accounts.sorted().map { store.read($0) }
15 for token in [old, SignInLifetimes().current] {
16 for change in [DeviceAccounts.Change.save(account), .remove(account), .route("pairing")] {
17 #expect(throws: CancellationError.self) { try accounts.commit(change, lifetime: token) }
18 }
19 }
20 #expect(store.accounts.sorted().map { store.read($0) } == before)
21 let next = accounts.lifetimes.begin()
22 #expect(!old.isActive)
23 #expect(next !== old)
24 try accounts.commit(.remove(account), lifetime: next)
25 #expect(accounts.all().isEmpty)
26 }
27}
28