Skip to content

Commit 2fbff11

Browse files
committed
more fixes for inflight-features
1 parent a668184 commit 2fbff11

File tree

3 files changed

+26
-25
lines changed

3 files changed

+26
-25
lines changed

codegen/smithy-kotlin-codegen/src/main/kotlin/software/amazon/smithy/kotlin/codegen/rendering/ShapeValueGenerator.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ class ShapeValueGenerator(
222222
val currSymbol = generator.symbolProvider.toSymbol(currShape)
223223
val memberName = generator.symbolProvider.toMemberName(member)
224224
val variantName = memberName.replaceFirstChar { c -> c.uppercaseChar() }
225-
writer.writeInline("${currSymbol.name}.$variantName(")
225+
writer.writeInline("#T.#L(", currSymbol, variantName)
226226
generator.instantiateShapeInline(writer, memberShape, valueNode)
227227
writer.writeInline(")")
228228
}

codegen/smithy-kotlin-codegen/src/main/kotlin/software/amazon/smithy/kotlin/codegen/rendering/smoketests/SmokeTestsRunnerGenerator.kt

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -132,18 +132,19 @@ class SmokeTestsRunnerGenerator(
132132
}
133133
write("")
134134
withInlineBlock("try {", "} ") {
135-
renderClient(testCase)
136-
renderOperation(operation, testCase)
135+
renderTestCase(operation, testCase)
137136
}
138137
withBlock("catch (exception: Exception) {", "}") {
139138
renderCatchBlock(testCase)
140139
}
141140
}
142141
}
143142

144-
private fun renderClient(testCase: SmokeTestCase) {
145-
writer.withInlineBlock("#T {", "}", service) {
143+
private fun renderTestCase(operation: OperationShape, testCase: SmokeTestCase) {
144+
writer.withBlock("#T {", "}", service) {
146145
renderClientConfig(testCase)
146+
closeAndOpenBlock("}.#T { client ->", RuntimeTypes.Core.IO.use)
147+
renderOperation(operation, testCase)
147148
}
148149
}
149150

@@ -159,10 +160,8 @@ class SmokeTestsRunnerGenerator(
159160
return
160161
}
161162

162-
testCase.clientConfig!!.forEach { config ->
163-
val name = config.key.value.toCamelCase()
164-
val value = config.value.format()
165-
163+
testCase.clientConfig.forEach { (name, unformattedValue) ->
164+
val value = unformattedValue.format()
166165
writer.declareSection(
167166
SmokeTestSectionIds.ClientConfig,
168167
mapOf(
@@ -172,24 +171,22 @@ class SmokeTestsRunnerGenerator(
172171
EndpointParams to EndpointParametersGenerator.getSymbol(settings),
173172
),
174173
) {
175-
writer.writeInline("#L = #L", name, value)
174+
writer.write("#L = #L", name, value)
176175
}
177176
}
178177
}
179178

180179
private fun renderOperation(operation: OperationShape, testCase: SmokeTestCase) {
181-
writer.withBlock(".#T { client ->", "}", RuntimeTypes.Core.IO.use) {
182-
val inputParams = testCase.params.getOrNull()
180+
val inputParams = testCase.params.getOrNull()
183181

184-
writeInline("client.#L", operation.defaultName())
182+
writer.writeInline("client.#L", operation.defaultName())
185183

186-
if (inputParams == null) {
187-
write("()")
188-
} else {
189-
withBlock("(", ")") {
190-
val inputShape = model.expectShape(operation.input.get())
191-
ShapeValueGenerator(model, symbolProvider).instantiateShapeInline(writer, inputShape, inputParams)
192-
}
184+
if (inputParams == null) {
185+
writer.write("()")
186+
} else {
187+
writer.withBlock("(", ")") {
188+
val inputShape = model.expectShape(operation.input.get())
189+
ShapeValueGenerator(model, symbolProvider).instantiateShapeInline(writer, inputShape, inputParams)
193190
}
194191
}
195192
}
@@ -277,8 +274,12 @@ class SmokeTestsRunnerGenerator(
277274
/**
278275
* Get the client configuration required for a [SmokeTestCase]
279276
*/
280-
private val SmokeTestCase.clientConfig: MutableMap<StringNode, Node>?
281-
get() = this.vendorParams.get().members
277+
private val SmokeTestCase.clientConfig: Map<String, Node>
278+
get() = vendorParams
279+
.getOrNull()
280+
?.members
281+
?.mapKeys { (key, _) -> key.value }
282+
.orEmpty()
282283

283284
// Constants
284285
private val model = ctx.model

codegen/smithy-kotlin-codegen/src/test/kotlin/software/amazon/smithy/kotlin/codegen/rendering/smoketests/SmokeTestsRunnerGeneratorTest.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ class SmokeTestsRunnerGeneratorTest {
3030
}
3131
vendorParamsShape: AwsVendorParams,
3232
vendorParams: {
33-
region: "eu-central-1"
33+
region: "eu-central-1",
34+
uri: "https://foo.amazon.com"
3435
}
3536
}
3637
{
@@ -109,6 +110,7 @@ class SmokeTestsRunnerGeneratorTest {
109110
TestClient {
110111
interceptors.add(SmokeTestsInterceptor())
111112
region = "eu-central-1"
113+
uri = "https://foo.amazon.com"
112114
}.use { client ->
113115
client.testOperation(
114116
TestOperationRequest {
@@ -144,7 +146,6 @@ class SmokeTestsRunnerGeneratorTest {
144146
145147
try {
146148
TestClient {
147-
148149
}.use { client ->
149150
client.testOperation(
150151
TestOperationRequest {
@@ -181,7 +182,6 @@ class SmokeTestsRunnerGeneratorTest {
181182
try {
182183
TestClient {
183184
interceptors.add(SmokeTestsInterceptor())
184-
185185
}.use { client ->
186186
client.testOperation(
187187
TestOperationRequest {

0 commit comments

Comments
 (0)