Skip to content

Commit c03b268

Browse files
authored
fix: Don't generate smoke tests for any streaming operation (#1001)
1 parent 9479456 commit c03b268

File tree

1 file changed

+12
-1
lines changed
  • smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/integration

1 file changed

+12
-1
lines changed

smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/integration/SmokeTestGenerator.kt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,22 @@
11
package software.amazon.smithy.swift.codegen.integration
22

33
import software.amazon.smithy.model.node.ObjectNode
4+
import software.amazon.smithy.model.shapes.MemberShape
45
import software.amazon.smithy.model.shapes.ShapeId
6+
import software.amazon.smithy.model.shapes.StructureShape
7+
import software.amazon.smithy.model.traits.StreamingTrait
58
import software.amazon.smithy.smoketests.traits.SmokeTestCase
69
import software.amazon.smithy.smoketests.traits.SmokeTestsTrait
710
import software.amazon.smithy.swift.codegen.ShapeValueGenerator
811
import software.amazon.smithy.swift.codegen.SwiftWriter
12+
import software.amazon.smithy.swift.codegen.model.expectShape
913
import software.amazon.smithy.swift.codegen.model.expectTrait
1014
import software.amazon.smithy.swift.codegen.model.hasTrait
1115
import software.amazon.smithy.swift.codegen.swiftmodules.ClientRuntimeTypes
1216
import software.amazon.smithy.swift.codegen.swiftmodules.FoundationTypes
1317
import software.amazon.smithy.swift.codegen.utils.toLowerCamelCase
1418
import software.amazon.smithy.swift.codegen.utils.toUpperCamelCase
19+
import kotlin.jvm.optionals.getOrNull
1520

1621
open class SmokeTestGenerator(
1722
private val ctx: ProtocolGenerator.GenerationContext,
@@ -55,7 +60,13 @@ open class SmokeTestGenerator(
5560
private fun getOperationShapeIdToTestCasesMapping(serviceName: String): Map<ShapeId, List<SmokeTestCase>> {
5661
val operationShapeIdToTestCases = mutableMapOf<ShapeId, List<SmokeTestCase>>()
5762
ctx.model.operationShapes.forEach { op ->
58-
if (ctx.model.expectShape(op.id).hasTrait<SmokeTestsTrait>()) {
63+
val input = op.input.getOrNull()?.let { ctx.model.expectShape<StructureShape>(it) }
64+
val output = op.output.getOrNull()?.let { ctx.model.expectShape<StructureShape>(it) }
65+
val operationHasEventStreams =
66+
((input?.members() ?: listOf<MemberShape>()) + (output?.members() ?: listOf())).any { member ->
67+
ctx.model.expectShape(member.target).hasTrait<StreamingTrait>()
68+
}
69+
if (op.hasTrait<SmokeTestsTrait>() && !operationHasEventStreams) {
5970
val testCases = mutableListOf<SmokeTestCase>()
6071
val smokeTestTrait = ctx.model.expectShape(op.id).expectTrait<SmokeTestsTrait>()
6172
smokeTestTrait.testCases.forEach { testCase ->

0 commit comments

Comments
 (0)