summaryrefslogtreecommitdiff
path: root/HutchTests/SRHTClientTests.swift
diff options
context:
space:
mode:
Diffstat (limited to 'HutchTests/SRHTClientTests.swift')
-rw-r--r--HutchTests/SRHTClientTests.swift27
1 files changed, 27 insertions, 0 deletions
diff --git a/HutchTests/SRHTClientTests.swift b/HutchTests/SRHTClientTests.swift
new file mode 100644
index 0000000..2ce2529
--- /dev/null
+++ b/HutchTests/SRHTClientTests.swift
@@ -0,0 +1,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).")
+ }
+ }
+}