summaryrefslogtreecommitdiff
path: root/HutchTests
diff options
context:
space:
mode:
authorChristian Cleberg <[email protected]>2026-08-07 03:27:37 -0500
committerChristian Cleberg <[email protected]>2026-08-07 03:27:37 -0500
commit89c90d11d80fde63997ca029e14806df0319a541 (patch)
treed4b6b57bc7648d8b1137b1d22bb09d6f2d44b093 /HutchTests
parent6c26cf048119bf4ff6af039991d3e34d76bac2ad (diff)
downloadhutch-89c90d11d80fde63997ca029e14806df0319a541.tar.gz
hutch-89c90d11d80fde63997ca029e14806df0319a541.tar.bz2
hutch-89c90d11d80fde63997ca029e14806df0319a541.zip
Sync bundled man page catalog from man.sr.ht (#7)
The More tab's official man-page list was a hardcoded array, updated by hand. Move it to a checked-in Hutch/Resources/man-pages.json (bundled via the synchronized group) loaded by a new ManPageCatalog, with the previous list kept as a built-in fallback. Add scripts/sync_man_pages.py, which re-derives the catalog from the man.sr.ht landing page, and a weekly scheduled workflow that runs it and opens a pull request when the list diverges upstream. The script refuses to write a suspiciously short list so a markup change can't gut the catalog. This first sync also picks up chat.sr.ht, which upstream added since the list was last hand-edited. Tests cover catalog loading, the fallback, and JSON decoding.
Diffstat (limited to 'HutchTests')
-rw-r--r--HutchTests/ManPageCatalogTests.swift35
1 files changed, 35 insertions, 0 deletions
diff --git a/HutchTests/ManPageCatalogTests.swift b/HutchTests/ManPageCatalogTests.swift
new file mode 100644
index 0000000..df995f8
--- /dev/null
+++ b/HutchTests/ManPageCatalogTests.swift
@@ -0,0 +1,35 @@
+import Foundation
+import Testing
+@testable import Hutch
+
+struct ManPageCatalogTests {
+ @Test
+ func loadsBundledCatalog() {
+ let entries = ManPageCatalog.load()
+ #expect(!entries.isEmpty)
+ #expect(entries.contains { $0.title == "git.sr.ht" })
+ #expect(entries.allSatisfy { $0.url.scheme == "https" })
+ }
+
+ @Test
+ func fallsBackWhenResourceMissing() {
+ // Foundation's own bundle has no man-pages.json, so this exercises the
+ // fallback path rather than the bundled resource.
+ let entries = ManPageCatalog.load(bundle: Bundle(for: JSONDecoder.self))
+ #expect(entries == ManPageCatalog.fallback)
+ }
+
+ @Test
+ func decodesCatalogJSON() throws {
+ let json = """
+ [
+ { "title": "git.sr.ht", "url": "https://man.sr.ht/git.sr.ht/" },
+ { "title": "srht.site", "url": "https://srht.site/" }
+ ]
+ """
+ let entries = try JSONDecoder().decode([ManPageCatalogEntry].self, from: Data(json.utf8))
+ #expect(entries.count == 2)
+ #expect(entries.first?.title == "git.sr.ht")
+ #expect(entries.first?.url == URL(string: "https://man.sr.ht/git.sr.ht/"))
+ }
+}