mirror of
https://codeberg.org/secana/ForgejoKit.git
synced 2026-06-16 05:13:53 -07:00
New model: - Token — id, name, sha1, tokenLastEight New services: - AdminService — createUser() - UserService — createToken() RepositoryService additions: - createRepository() - editRepository() - createLabel() - createMilestone() - addCollaborator() - createFile() remove MARKS
36 lines
1.3 KiB
Swift
36 lines
1.3 KiB
Swift
import Foundation
|
|
import Testing
|
|
@testable import ForgejoKit
|
|
|
|
struct AdminServiceTests {
|
|
|
|
@Test func createUserPayloadEncodesCorrectKeys() 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 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 createUserURLConstruction() 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")
|
|
}
|
|
}
|