1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
|
import Foundation
import Testing
@testable import Hutch
@MainActor
struct DeepLinkTests {
@Test
func parsesHomeLink() {
let link = DeepLink(url: HutchDeepLinkURL.home)
#expect(link == .home)
}
@Test
func parsesNilPathAsHome() {
let link = DeepLink(url: HutchDeepLinkURL.emptyHost)
#expect(link == .home)
}
@Test
func parsesRepositoryLink() {
let link = DeepLink(url: HutchDeepLinkURL.repositoryGit)
#expect(link == .repository(service: .git, owner: "~user", repo: "repo"))
}
@Test
func parsesHgRepositoryLink() {
let link = DeepLink(url: HutchDeepLinkURL.repositoryHg)
#expect(link == .repository(service: .hg, owner: "~user", repo: "repo"))
}
@Test
func parsesServiceOwnerRootAsUserProfile() {
let link = DeepLink(url: HutchDeepLinkURL.gitOwnerRoot)
#expect(link == .userProfile(owner: "~owner"))
}
@Test
func parsesTicketLink() {
let link = DeepLink(url: HutchDeepLinkURL.ticket)
#expect(link == .ticket(owner: "~owner", tracker: "tracker", ticketId: 42))
}
@Test
func parsesBuildJobLink() {
let link = DeepLink(url: HutchDeepLinkURL.buildJob)
#expect(link == .build(jobId: 12345))
}
@Test
func parsesBuildJobLinkWithOwnerPath() {
let link = DeepLink(url: HutchDeepLinkURL.buildJobWithOwner)
#expect(link == .build(jobId: 12345))
}
@Test
func parsesMailingListLink() {
let link = DeepLink(url: HutchDeepLinkURL.mailingList)
#expect(link == .mailingList(owner: "~owner", list: "list"))
}
@Test
func parsesBuildsTabLink() {
let link = DeepLink(url: HutchDeepLinkURL.builds)
#expect(link == .buildsTab)
}
@Test
func parsesRepositoriesTabLink() {
let link = DeepLink(url: HutchDeepLinkURL.repositories)
#expect(link == .repositoriesTab)
}
@Test
func parsesTrackersTabLink() {
let link = DeepLink(url: HutchDeepLinkURL.trackers)
#expect(link == .trackersTab)
}
@Test
func parsesSystemStatusLink() {
let link = DeepLink(url: HutchDeepLinkURL.status)
#expect(link == .systemStatus)
}
@Test
func parsesLookupLink() {
let link = DeepLink(url: HutchDeepLinkURL.lookup)
#expect(link == .lookup)
}
@Test
func parsesRouteBackedNavigationLinks() {
#expect(DeepLink(url: HutchRoute.workQueue(scope: .assigned).url) == .workQueue(scope: .assigned))
#expect(DeepLink(url: HutchRoute.failedBuilds.url) == .failedBuilds)
#expect(DeepLink(url: HutchRoute.search(query: "patch queue", type: nil).url) == .search(query: "patch queue", type: nil))
#expect(DeepLink(url: HutchRoute.search(query: "~alice", type: .user).url) == .search(query: "~alice", type: .user))
#expect(DeepLink(url: HutchRoute.projectDashboard(id: "project-1", title: "Hutch").url) == .projectDashboard(id: "project-1", title: "Hutch"))
}
@Test
func parsesUserProfileLink() {
let link = DeepLink(url: HutchDeepLinkURL.userProfile)
#expect(link == .userProfile(owner: "~owner"))
}
@Test
func rejectsNonHutchScheme() {
let link = DeepLink(url: URL(string: "https://example.com/home")!)
#expect(link == nil)
}
@Test
func rejectsUnknownPath() {
let link = DeepLink(url: HutchDeepLinkURL.unknown)
#expect(link == nil)
}
@Test
func rejectsTicketLinkWithNonNumericId() {
let link = DeepLink(url: HutchDeepLinkURL.invalidTicketId)
#expect(link == nil)
}
@Test
func rejectsBuildLinkWithNonNumericId() {
let link = DeepLink(url: HutchDeepLinkURL.invalidBuildId)
#expect(link == nil)
}
}
|