Skip to content

Commit 7a30766

Browse files
authored
Test decorators in server tests (#3107)
This change allows to test decorators by adding them to the CodegenContext. ---- _By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice._ --------- Signed-off-by: Daniele Ahmed <[email protected]>
1 parent a9b9cba commit 7a30766

File tree

1 file changed

+5
-7
lines changed
  • codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/testutil

1 file changed

+5
-7
lines changed

codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/testutil/ServerTestHelpers.kt

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import software.amazon.smithy.rust.codegen.server.smithy.ServerModuleProvider
2828
import software.amazon.smithy.rust.codegen.server.smithy.ServerRustSettings
2929
import software.amazon.smithy.rust.codegen.server.smithy.ServerSymbolProviders
3030
import software.amazon.smithy.rust.codegen.server.smithy.customizations.SmithyValidationExceptionConversionGenerator
31+
import software.amazon.smithy.rust.codegen.server.smithy.customize.CombinedServerCodegenDecorator
3132
import software.amazon.smithy.rust.codegen.server.smithy.customize.ServerCodegenDecorator
3233
import software.amazon.smithy.rust.codegen.server.smithy.generators.ServerBuilderGenerator
3334
import software.amazon.smithy.rust.codegen.server.smithy.generators.protocol.ServerProtocol
@@ -47,15 +48,11 @@ private fun testServiceShapeFor(model: Model) =
4748
fun serverTestSymbolProvider(model: Model, serviceShape: ServiceShape? = null) =
4849
serverTestSymbolProviders(model, serviceShape).symbolProvider
4950

50-
private class ServerTestCodegenDecorator : ServerCodegenDecorator {
51-
override val name = "test"
52-
override val order: Byte = 0
53-
}
54-
5551
fun serverTestSymbolProviders(
5652
model: Model,
5753
serviceShape: ServiceShape? = null,
5854
settings: ServerRustSettings? = null,
55+
decorators: List<ServerCodegenDecorator> = emptyList(),
5956
) =
6057
ServerSymbolProviders.from(
6158
serverTestRustSettings(),
@@ -67,7 +64,7 @@ fun serverTestSymbolProviders(
6764
(serviceShape ?: testServiceShapeFor(model)).id,
6865
)
6966
).codegenConfig.publicConstrainedTypes,
70-
ServerTestCodegenDecorator(),
67+
CombinedServerCodegenDecorator(decorators),
7168
RustServerCodegenPlugin::baseSymbolProvider,
7269
)
7370

@@ -102,6 +99,7 @@ fun serverTestCodegenContext(
10299
serviceShape: ServiceShape? = null,
103100
settings: ServerRustSettings = serverTestRustSettings(),
104101
protocolShapeId: ShapeId? = null,
102+
decorators: List<ServerCodegenDecorator> = emptyList(),
105103
): ServerCodegenContext {
106104
val service = serviceShape ?: testServiceShapeFor(model)
107105
val protocol = protocolShapeId ?: ShapeId.from("test#Protocol")
@@ -111,7 +109,7 @@ fun serverTestCodegenContext(
111109
service,
112110
ServerTestRustSymbolProviderConfig,
113111
settings.codegenConfig.publicConstrainedTypes,
114-
ServerTestCodegenDecorator(),
112+
CombinedServerCodegenDecorator(decorators),
115113
RustServerCodegenPlugin::baseSymbolProvider,
116114
)
117115

0 commit comments

Comments
 (0)