krz/hutch
an ios client for sourcehut
clone: git clone https://gitbay.org/krz/hutch.git
v3.1.6: HutchTests/DeepLinkTests.swift · raw
1import Foundation
2import Testing
3@testable import Hutch
4
5struct DeepLinkTests {
6
7 @Test
8 func parsesHomeLink() {
9 let link = DeepLink(url: HutchDeepLinkURL.home)
10 #expect(link == .home)
11 }
12
13 @Test
14 func parsesNilPathAsHome() {
15 let link = DeepLink(url: HutchDeepLinkURL.emptyHost)
16 #expect(link == .home)
17 }
18
19 @Test
20 func parsesRepositoryLink() {
21 let link = DeepLink(url: HutchDeepLinkURL.repositoryGit)
22 #expect(link == .repository(owner: "~user", repo: "repo"))
23 }
24
25 @Test
26 func parsesTicketLink() {
27 let link = DeepLink(url: HutchDeepLinkURL.ticket)
28 #expect(link == .ticket(owner: "~owner", tracker: "tracker", ticketId: 42))
29 }
30
31 @Test
32 func parsesBuildJobLink() {
33 let link = DeepLink(url: HutchDeepLinkURL.buildJob)
34 #expect(link == .build(jobId: 12345))
35 }
36
37 @Test
38 func parsesBuildsTabLink() {
39 let link = DeepLink(url: HutchDeepLinkURL.builds)
40 #expect(link == .buildsTab)
41 }
42
43 @Test
44 func parsesRepositoriesTabLink() {
45 let link = DeepLink(url: HutchDeepLinkURL.repositories)
46 #expect(link == .repositoriesTab)
47 }
48
49 @Test
50 func parsesTrackersTabLink() {
51 let link = DeepLink(url: HutchDeepLinkURL.trackers)
52 #expect(link == .trackersTab)
53 }
54
55 @Test
56 func parsesSystemStatusLink() {
57 let link = DeepLink(url: HutchDeepLinkURL.status)
58 #expect(link == .systemStatus)
59 }
60
61 @Test
62 func parsesLookupLink() {
63 let link = DeepLink(url: HutchDeepLinkURL.lookup)
64 #expect(link == .lookup)
65 }
66
67 @Test
68 func rejectsNonHutchScheme() {
69 let link = DeepLink(url: URL(string: "https://example.com/home")!)
70 #expect(link == nil)
71 }
72
73 @Test
74 func rejectsUnknownPath() {
75 let link = DeepLink(url: HutchDeepLinkURL.unknown)
76 #expect(link == nil)
77 }
78
79 @Test
80 func rejectsTicketLinkWithNonNumericId() {
81 let link = DeepLink(url: HutchDeepLinkURL.invalidTicketId)
82 #expect(link == nil)
83 }
84
85 @Test
86 func rejectsBuildLinkWithNonNumericId() {
87 let link = DeepLink(url: HutchDeepLinkURL.invalidBuildId)
88 #expect(link == nil)
89 }
90}