make the thing

This commit is contained in:
2026-08-31 21:56:09 +02:00
parent 3615193ae4
commit f8b5923079
20 changed files with 931 additions and 34 deletions
+26 -4
View File
@@ -1,8 +1,30 @@
import Foundation
import Testing
@testable import aria
@Test func example() async throws {
// Write your test here and use APIs like `#expect(...)` to check expected conditions.
// Swift Testing Documentation
// https://developer.apple.com/documentation/testing
@Test func addUriParamsEncodesPositionalArray() throws {
let params = Aria2.AddUriParams(
secret: "s3cret",
uris: ["https://example.com/file.zip"],
options: ["dir": "/tmp"]
)
let data = try JSONEncoder().encode(params)
let value = try JSONSerialization.jsonObject(with: data) as! [Any]
#expect(value.count == 3)
#expect(value[0] as? String == "token:s3cret")
#expect(value[1] as? [String] == ["https://example.com/file.zip"])
#expect(value[2] as? [String: String] == ["dir": "/tmp"])
}
@Test func addUriParamsOmitsSecretAndOptions() throws {
let params = Aria2.AddUriParams(secret: nil, uris: ["magnet:?xt=1"], options: [:])
let data = try JSONEncoder().encode(params)
let value = try JSONSerialization.jsonObject(with: data) as! [Any]
#expect(value.count == 1)
#expect(value[0] as? [String] == ["magnet:?xt=1"])
}