summaryrefslogtreecommitdiff
path: root/HutchTests/ManPageCatalogTests.swift
diff options
context:
space:
mode:
authorChristian Cleberg <[email protected]>2026-08-07 03:45:47 -0500
committerGitHub <[email protected]>2026-08-07 03:45:47 -0500
commitdb40d346c28800a1eec384a5e4f3d7d090198e4d (patch)
treecebd9fb63f26e402b85f5db4192f5dc844c48a27 /HutchTests/ManPageCatalogTests.swift
parent6c26cf048119bf4ff6af039991d3e34d76bac2ad (diff)
parentf9f86b9681909b14304909b1286b9b50362625d7 (diff)
downloadhutch-db40d346c28800a1eec384a5e4f3d7d090198e4d.tar.gz
hutch-db40d346c28800a1eec384a5e4f3d7d090198e4d.tar.bz2
hutch-db40d346c28800a1eec384a5e4f3d7d090198e4d.zip
Merge pull request #32 from krazywarez/sync-man-pages
Sync bundled man page catalog from man.sr.ht (#7)
Diffstat (limited to 'HutchTests/ManPageCatalogTests.swift')
-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/"))
+ }
+}