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
|
import Foundation
import Testing
@testable import Hutch
struct SRHTWebURLTests {
private let repository = RepositorySummary(
id: 1,
rid: "repo-1",
service: .git,
name: "hutch",
description: nil,
visibility: .public,
updated: .distantPast,
owner: Entity(canonicalName: "~ccleberg"),
head: nil
)
private let tracker = TrackerSummary(
id: 2,
rid: "tracker-1",
name: "todo",
description: nil,
visibility: .public,
updated: .distantPast,
owner: Entity(canonicalName: "~ccleberg")
)
@Test
func browserOnlyServiceURLsUseCanonicalHosts() {
#expect(SRHTWebURL.chat.absoluteString == "https://chat.sr.ht")
#expect(SRHTWebURL.status.absoluteString == "https://status.sr.ht")
}
@Test
func repositoryAndCloneURLsUseStableUserScopedPaths() {
#expect(SRHTWebURL.repository(repository)?.absoluteString == "https://git.sr.ht/~ccleberg/hutch")
#expect(SRHTWebURL.httpsCloneURL(repository) == "https://git.sr.ht/~ccleberg/hutch")
#expect(SRHTWebURL.sshCloneURL(repository) == "[email protected]:~ccleberg/hutch")
}
@Test
func trackerTicketAndBuildURLsUseStableUserScopedPaths() {
#expect(SRHTWebURL.tracker(tracker)?.absoluteString == "https://todo.sr.ht/~ccleberg/todo")
#expect(SRHTWebURL.ticket(ownerUsername: "ccleberg", trackerName: "todo", ticketId: 42)?.absoluteString == "https://todo.sr.ht/~ccleberg/todo/42")
#expect(SRHTWebURL.build(jobId: 12, ownerCanonicalName: "~ccleberg")?.absoluteString == "https://builds.sr.ht/~ccleberg/job/12")
}
}
|