blob: 2ce2529e166c64d86694ac1b660e1df553590ff3 (
plain) (
blame)
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
|
import Foundation
import Testing
@testable import Hutch
struct SRHTClientTests {
@Test
@MainActor
func fetchTextRejectsUnexpectedAuthenticatedURL() async throws {
let client = SRHTClient(token: "test-token")
let url = try #require(URL(string: "https://example.com/build-log"))
do {
_ = try await client.fetchText(url: url)
Issue.record("Expected fetchText(url:) to reject non-sr.ht URLs.")
} catch let error as SRHTError {
guard case .invalidAuthenticatedURL(let rejectedURL) = error else {
Issue.record("Expected invalidAuthenticatedURL error, got \(error).")
return
}
#expect(rejectedURL == url)
} catch {
Issue.record("Expected SRHTError.invalidAuthenticatedURL, got \(error).")
}
}
}
|