mirror of
https://codeberg.org/secana/ForgejoKit.git
synced 2026-06-16 05:13:53 -07:00
- 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
50 lines
1.8 KiB
Swift
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")
|
|
}
|
|
}
|