aboutsummaryrefslogtreecommitdiff
path: root/Tests/ariaTests/ariaTests.swift
diff options
context:
space:
mode:
authorTommaso Negri <me@tommasongr.com>2026-08-31 21:56:09 +0200
committerTommaso Negri <me@tommasongr.com>2026-08-31 21:56:09 +0200
commitf8b59230794a6d1c22a48d06388a72b70bc6380f (patch)
tree0d65005989d70e6810688da0c0a0f95dbfed7a28 /Tests/ariaTests/ariaTests.swift
parent3615193ae44bf4afbc315e5e97d8f3d909e7c16b (diff)
downloadaria-f8b59230794a6d1c22a48d06388a72b70bc6380f.tar.gz
aria-f8b59230794a6d1c22a48d06388a72b70bc6380f.zip
make the thing
Diffstat (limited to 'Tests/ariaTests/ariaTests.swift')
-rw-r--r--Tests/ariaTests/ariaTests.swift30
1 files changed, 26 insertions, 4 deletions
diff --git a/Tests/ariaTests/ariaTests.swift b/Tests/ariaTests/ariaTests.swift
index 230a507..6f8162e 100644
--- a/Tests/ariaTests/ariaTests.swift
+++ b/Tests/ariaTests/ariaTests.swift
@@ -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"])
}