ForgejoKit/Tests/ForgejoKitTests/NormalizeServerURLTests.swift

51 lines
1.7 KiB
Swift
Raw Normal View History

2026-06-04 02:29:23 -07:00
@testable import ForgejoKit
import Foundation
import Testing
struct NormalizeServerURLTests {
2026-06-15 03:06:27 -07:00
@Test func stripsTrailingSlash() {
let result = ForgejoClient.normalizeServerURL("https://forgejo.example.com/")
#expect(result == "https://forgejo.example.com")
}
2026-06-15 03:06:27 -07:00
@Test func addsHttpsWhenNoScheme() {
let result = ForgejoClient.normalizeServerURL("forgejo.example.com")
#expect(result == "https://forgejo.example.com")
}
2026-06-15 03:06:27 -07:00
@Test func preservesHttpScheme() {
let result = ForgejoClient.normalizeServerURL("http://localhost:3000")
#expect(result == "http://localhost:3000")
}
2026-06-15 03:06:27 -07:00
@Test func preservesHttpsScheme() {
let result = ForgejoClient.normalizeServerURL("https://forgejo.example.com")
#expect(result == "https://forgejo.example.com")
}
2026-06-15 03:06:27 -07:00
@Test func trimsWhitespace() {
let result = ForgejoClient.normalizeServerURL(" https://forgejo.example.com ")
#expect(result == "https://forgejo.example.com")
}
2026-06-15 03:06:27 -07:00
@Test func handlesTrailingSlashAndWhitespace() {
let result = ForgejoClient.normalizeServerURL(" forgejo.example.com/ ")
#expect(result == "https://forgejo.example.com")
}
2026-06-15 03:06:27 -07:00
@Test func preservesPort() {
let result = ForgejoClient.normalizeServerURL("https://forgejo.example.com:3000")
#expect(result == "https://forgejo.example.com:3000")
}
2026-06-15 03:06:27 -07:00
@Test func preservesPath() {
let result = ForgejoClient.normalizeServerURL("https://example.com/forgejo")
#expect(result == "https://example.com/forgejo")
}
2026-06-15 03:06:27 -07:00
@Test func stripsMultipleTrailingSlashes() {
let result = ForgejoClient.normalizeServerURL("https://example.com///")
#expect(result == "https://example.com")
}
}