diff options
Diffstat (limited to 'HutchTests')
| -rw-r--r-- | HutchTests/SRHTWebURLTests.swift | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/HutchTests/SRHTWebURLTests.swift b/HutchTests/SRHTWebURLTests.swift index 15f242d..a183f00 100644 --- a/HutchTests/SRHTWebURLTests.swift +++ b/HutchTests/SRHTWebURLTests.swift @@ -3,10 +3,44 @@ 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") + } } |
