summaryrefslogtreecommitdiff
path: root/HutchTests/SystemStatusWidgetSnapshotTests.swift
diff options
context:
space:
mode:
authorChristian Cleberg <[email protected]>2026-04-12 23:19:20 -0500
committerChristian Cleberg <[email protected]>2026-04-12 23:19:20 -0500
commitee9f2904aa319231b7047fca3cb069f0c07019cd (patch)
tree69a18234512c63f38f0d477e0023969698ec3c9e /HutchTests/SystemStatusWidgetSnapshotTests.swift
parent72f860e0e171f6aac4e7d896e7a571147dbcb5c5 (diff)
downloadhutch-ee9f2904aa319231b7047fca3cb069f0c07019cd.tar.gz
hutch-ee9f2904aa319231b7047fca3cb069f0c07019cd.tar.bz2
hutch-ee9f2904aa319231b7047fca3cb069f0c07019cd.zip
feat: add multi-account support
Implements: https://todo.sr.ht/~ccleberg/hutch/49 Implements: https://todo.sr.ht/~ccleberg/hutch/50 Implements: https://todo.sr.ht/~ccleberg/hutch/51
Diffstat (limited to 'HutchTests/SystemStatusWidgetSnapshotTests.swift')
-rw-r--r--HutchTests/SystemStatusWidgetSnapshotTests.swift31
1 files changed, 31 insertions, 0 deletions
diff --git a/HutchTests/SystemStatusWidgetSnapshotTests.swift b/HutchTests/SystemStatusWidgetSnapshotTests.swift
index ddb74b1..7121804 100644
--- a/HutchTests/SystemStatusWidgetSnapshotTests.swift
+++ b/HutchTests/SystemStatusWidgetSnapshotTests.swift
@@ -65,6 +65,37 @@ struct SystemStatusWidgetSnapshotTests {
}
@Test
+ func snapshotsAreIsolatedPerAccount() {
+ let defaultsName = "SystemStatusWidgetSnapshotTests-isolation-\(UUID().uuidString)"
+ let defaults = UserDefaults(suiteName: defaultsName)!
+ defer { defaults.removePersistentDomain(forName: defaultsName) }
+
+ let firstSnapshot = SystemStatusWidgetSnapshot(
+ services: [.init(id: "git", name: "git.sr.ht", status: "Operational", requiresAttention: false)],
+ hasDisruption: false,
+ overallStatusText: "All monitored services operational",
+ bannerSummary: "",
+ updatedAt: Date(timeIntervalSince1970: 100)
+ )
+ let secondSnapshot = SystemStatusWidgetSnapshot(
+ services: [.init(id: "builds", name: "builds.sr.ht", status: "Degraded", requiresAttention: true)],
+ hasDisruption: true,
+ overallStatusText: "Experiencing disruptions",
+ bannerSummary: "builds.sr.ht disrupted",
+ updatedAt: Date(timeIntervalSince1970: 200)
+ )
+
+ SystemStatusWidgetSnapshotStore.save(firstSnapshot, accountID: "account-a", defaults: defaults)
+ SystemStatusWidgetSnapshotStore.save(secondSnapshot, accountID: "account-b", defaults: defaults)
+
+ #expect(SystemStatusWidgetSnapshotStore.load(accountID: "account-a", defaults: defaults)?.services.first?.name == "git.sr.ht")
+ #expect(SystemStatusWidgetSnapshotStore.load(accountID: "account-b", defaults: defaults)?.services.first?.name == "builds.sr.ht")
+
+ ActiveAccountContextStore.save("account-b", defaults: defaults)
+ #expect(SystemStatusWidgetSnapshotStore.load(defaults: defaults)?.bannerSummary == "builds.sr.ht disrupted")
+ }
+
+ @Test
func unavailableSnapshotHasEmptyServices() {
let snapshot = SystemStatusWidgetSnapshot.unavailable
#expect(snapshot.services.isEmpty)