ForgejoKit/Tests/ForgejoKitTests/AdminServiceTests.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

35 lines
1.3 KiB
Swift

@testable import ForgejoKit
import Foundation
import Testing
struct AdminServiceTests {
@Test func `create user payload encodes correct keys`() throws {
let json = """
{
"username": "testbot",
"password": "testbot1234",
"email": "testbot@test.local",
"login_name": "testbot",
"full_name": "Test Bot",
"must_change_password": false,
"send_notify": false,
"source_id": 0,
"visibility": "public"
}
"""
let data = Data(json.utf8)
let dict = try #require(JSONSerialization.jsonObject(with: data) as? [String: Any])
#expect(dict["username"] as? String == "testbot")
#expect(dict["login_name"] as? String == "testbot")
#expect(dict["must_change_password"] as? Bool == false)
#expect(dict["send_notify"] as? Bool == false)
#expect(dict["source_id"] as? Int == 0)
#expect(dict["visibility"] as? String == "public")
}
@Test func `create user URL construction`() throws {
let client = ForgejoClient(serverURL: "https://forgejo.example.com", username: "admin", password: "pass")
let url = try client.makeURL(path: "/api/v1/admin/users")
#expect(url.absoluteString == "https://forgejo.example.com/api/v1/admin/users")
}
}