Skip to content

Commit 38ecf81

Browse files
authored
Merge pull request #266 from cashapp/skorulis/parse-target-resolver
Add targetResolver into the coding keys for Configuration
2 parents b7bb903 + 722eec3 commit 38ecf81

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

Sources/KnitCodeGen/Configuration.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ public struct Configuration: Encodable, Sendable {
5858
case assemblyType
5959
case registrations
6060
case replaces
61+
case targetResolver
6162
}
6263

6364
// Testing all registrations introduces complications, limit what is tested for simplicity

Tests/KnitCodeGenTests/RegistrationEncodingTests.swift

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,49 @@ final class RegistrationEncodingTests: XCTestCase {
6363
let reencoded = try decoder.decode(Registration.self, from: data)
6464
XCTAssertEqual(registration, reencoded)
6565
}
66+
67+
func testAssembly() throws {
68+
let assembly = Configuration(
69+
assemblyName: "MainAssembly",
70+
moduleName: "MyModule",
71+
registrations: [.init(service: "ServiceA")],
72+
targetResolver: "Resolver"
73+
)
74+
75+
let encoder = JSONEncoder()
76+
encoder.outputFormatting = [.prettyPrinted, .sortedKeys]
77+
let data = try encoder.encode(assembly)
78+
let text = try XCTUnwrap(String(data: data, encoding: .utf8))
79+
let expected = """
80+
{
81+
"assemblyName" : "MainAssembly",
82+
"assemblyType" : "ModuleAssembly",
83+
"directives" : {
84+
"custom" : [
85+
86+
],
87+
"disablePerformanceGen" : false
88+
},
89+
"registrations" : [
90+
{
91+
"accessLevel" : "internal",
92+
"arguments" : [
93+
94+
],
95+
"customTags" : [
96+
97+
],
98+
"functionName" : "register",
99+
"service" : "ServiceA"
100+
}
101+
],
102+
"replaces" : [
103+
104+
],
105+
"targetResolver" : "Resolver"
106+
}
107+
"""
108+
109+
XCTAssertEqual(text, expected)
110+
}
66111
}

0 commit comments

Comments
 (0)