ForgejoKit/Tests/ForgejoKitTests/NormalizeServerURLTests.swift
Stefan Hausotte b78c57ffd9 feat: add Attachment model and image upload support
- Add Attachment model with isImage computed property
- Add assets field to Issue, IssueComment, and PullRequest
- Add multipart/form-data upload support to ForgejoClient
- Add uploadIssueAttachment and uploadCommentAttachment to IssueService
2026-06-15 09:48:47 +02:00

50 lines
1.8 KiB
Swift

@testable import ForgejoKit
import Foundation
import Testing
struct NormalizeServerURLTests {
@Test func `strips trailing slash`() {
let result = ForgejoClient.normalizeServerURL("https://forgejo.example.com/")
#expect(result == "https://forgejo.example.com")
}
@Test func `adds https when no scheme`() {
let result = ForgejoClient.normalizeServerURL("forgejo.example.com")
#expect(result == "https://forgejo.example.com")
}
@Test func `preserves http scheme`() {
let result = ForgejoClient.normalizeServerURL("http://localhost:3000")
#expect(result == "http://localhost:3000")
}
@Test func `preserves https scheme`() {
let result = ForgejoClient.normalizeServerURL("https://forgejo.example.com")
#expect(result == "https://forgejo.example.com")
}
@Test func `trims whitespace`() {
let result = ForgejoClient.normalizeServerURL(" https://forgejo.example.com ")
#expect(result == "https://forgejo.example.com")
}
@Test func `handles trailing slash and whitespace`() {
let result = ForgejoClient.normalizeServerURL(" forgejo.example.com/ ")
#expect(result == "https://forgejo.example.com")
}
@Test func `preserves port`() {
let result = ForgejoClient.normalizeServerURL("https://forgejo.example.com:3000")
#expect(result == "https://forgejo.example.com:3000")
}
@Test func `preserves path`() {
let result = ForgejoClient.normalizeServerURL("https://example.com/forgejo")
#expect(result == "https://example.com/forgejo")
}
@Test func `strips multiple trailing slashes`() {
let result = ForgejoClient.normalizeServerURL("https://example.com///")
#expect(result == "https://example.com")
}
}