Skip to content

Commit ebb0600

Browse files
coenttbclaude
andcommitted
Consolidate and refactor URLFormCoding tests
- Merge separate decoder and encoder test files into unified URLFormCoding Tests - Update package dependencies and module structure - Improve conversion implementations for URL routing - Refactor multipart form handling with cleaner test structure - Remove redundant test files and consolidate test models Co-Authored-By: Claude <noreply@anthropic.com>
1 parent e1b5f0f commit ebb0600

File tree

10 files changed

+51
-1653
lines changed

10 files changed

+51
-1653
lines changed

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ let package = Package(
3737
.library(name: .multipartURLFormCodingURLRouting, targets: [.multipartURLFormCodingURLRouting])
3838
],
3939
dependencies: [
40-
.package(url: "https://github.com/coenttb/pointfree-url-form-coding.git", from: "0.0.1"),
40+
.package(url: "https://github.com/coenttb/pointfree-url-form-coding.git", from: "0.2.0"),
4141
.package(url: "https://github.com/pointfreeco/swift-dependencies", from: "1.1.5"),
4242
.package(url: "https://github.com/pointfreeco/swift-url-routing", from: "0.6.0")
4343
],

Package@swift-6.0.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ let package = Package(
3737
.library(name: .multipartURLFormCodingURLRouting, targets: [.multipartURLFormCodingURLRouting])
3838
],
3939
dependencies: [
40-
.package(url: "https://github.com/coenttb/pointfree-url-form-coding.git", from: "0.0.1"),
40+
.package(url: "https://github.com/coenttb/pointfree-url-form-coding.git", from: "0.2.0"),
4141
.package(url: "https://github.com/pointfreeco/swift-dependencies", from: "1.1.5"),
4242
.package(url: "https://github.com/pointfreeco/swift-url-routing", from: "0.6.0")
4343
],

Sources/URLMultipartFormCodingURLRouting/Conversion.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,10 @@ extension Conversion {
6767
/// ```
6868
public static func multipart<Value: Codable>(
6969
_ type: Value.Type,
70-
decoder: Form.Decoder = .init()
70+
decoder: Form.Decoder = .init(),
71+
encoder: Form.Encoder = .init()
7172
) -> Self where Self == Multipart.Conversion<Value> {
72-
.init(type, decoder: decoder)
73+
.init(type, decoder: decoder, encoder: encoder)
7374
}
7475
}
7576

Sources/URLMultipartFormCodingURLRouting/Multipart.Conversion.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ extension Multipart {
5757
public struct Conversion<Value: Codable> {
5858
/// The URL form decoder used for parsing input data.
5959
public let decoder: Form.Decoder
60+
public let encoder: Form.Encoder
6061

6162
/// The unique boundary string used to separate multipart fields.
6263
public let boundary: String
@@ -68,9 +69,11 @@ extension Multipart {
6869
/// - decoder: Custom URL form decoder (optional, uses default if not provided)
6970
public init(
7071
_ type: Value.Type,
71-
decoder: Form.Decoder = .init()
72+
decoder: Form.Decoder = .init(),
73+
encoder: Form.Encoder = .init()
7274
) {
7375
self.decoder = decoder
76+
self.encoder = encoder
7477
self.boundary = "Boundary-\(UUID().uuidString)"
7578
}
7679

@@ -120,7 +123,6 @@ extension Multipart.Conversion: URLRouting.Conversion {
120123
public func unapply(_ output: Value) -> Foundation.Data {
121124
var body = Data()
122125

123-
let encoder = JSONEncoder()
124126
guard let fieldData = try? encoder.encode(output),
125127
var fields = try? JSONSerialization.jsonObject(with: fieldData) as? [String: Any] else {
126128
return body

0 commit comments

Comments
 (0)