Skip to content

Commit d931daa

Browse files
authored
fix: test change needed to pass an import down to smithy swift (#362)
1 parent 19666b8 commit d931daa

File tree

4 files changed

+52
-2
lines changed

4 files changed

+52
-2
lines changed

Packages/ClientRuntime/Sources/PrimitiveTypeExtensions/Number+Extension.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,3 @@ public extension Double {
2828
}
2929
}
3030
}
31-
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
//
2+
// Copyright Amazon.com Inc. or its affiliates.
3+
// All Rights Reserved.
4+
//
5+
// SPDX-License-Identifier: Apache-2.0
6+
//
7+
8+
import ClientRuntime
9+
10+
public struct MockSerializeStreamMiddleware: Middleware {
11+
public func handle<H>(context: HttpContext,
12+
input: SerializeStepInput<MockStreamInput>,
13+
next: H) -> Result<OperationOutput<MockOutput>, SdkError<MockMiddlewareError>>
14+
where H: Handler, HttpContext == H.Context,
15+
SdkError<MockMiddlewareError> == H.MiddlewareError,
16+
SerializeStepInput<MockStreamInput> == H.Input,
17+
OperationOutput<MockOutput> == H.Output {
18+
input.builder.withBody(HttpBody.stream(input.operationInput.body))
19+
return next.handle(context: context, input: input)
20+
}
21+
22+
public init() {}
23+
24+
public var id: String = "MockSerializeStreamMiddleware"
25+
26+
public typealias MInput = SerializeStepInput<MockStreamInput>
27+
28+
public typealias MOutput = OperationOutput<MockOutput>
29+
30+
public typealias Context = HttpContext
31+
32+
public typealias MError = SdkError<MockMiddlewareError>
33+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//
2+
// Copyright Amazon.com Inc. or its affiliates.
3+
// All Rights Reserved.
4+
//
5+
// SPDX-License-Identifier: Apache-2.0
6+
//
7+
import ClientRuntime
8+
9+
public struct MockStreamInput: Reflection, Encodable {
10+
let body: ByteStream
11+
12+
public init(body: ByteStream) {
13+
self.body = body
14+
}
15+
}

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ class HttpProtocolTestGenerator(
3434
private val httpProtocolCustomizable: HttpProtocolCustomizable,
3535
private val operationMiddleware: OperationMiddleware,
3636
private val serdeContext: HttpProtocolUnitTestGenerator.SerdeContext,
37+
private val imports: List<String> = listOf(),
3738
// list of test IDs to ignore/skip
3839
private val testsToIgnore: Set<String> = setOf()
3940
) {
@@ -88,7 +89,9 @@ class HttpProtocolTestGenerator(
8889
val testFilename = "./${ctx.settings.moduleName}Tests/$testClassName.swift"
8990
ctx.delegator.useTestFileWriter(testFilename, ctx.settings.moduleName) { writer ->
9091
LOGGER.fine("Generating request protocol test cases for ${operation.id}")
91-
92+
for (import in imports) {
93+
writer.addImport(import)
94+
}
9295
writer.addImport(SwiftDependency.CLIENT_RUNTIME.target)
9396
writer.addImport(ctx.settings.moduleName, true)
9497
writer.addImport(SwiftDependency.SMITHY_TEST_UTIL.target)

0 commit comments

Comments
 (0)