Unverified Commit 38fbae5c authored by John DiSanti's avatar John DiSanti Committed by GitHub
Browse files

Enable paginators when code generating with the orchestrator (#2688)

## Motivation and Context
The paginators were originally turned off for the orchestrator feature
flag since there were issues with them, but those issues seem to have
been resolved since. This PR re-enables them.

## Testing
- [x] Generated the AWS SDK in `orchestrator` mode and verified the
paginator tests pass
- [x] Added a unit test that validates the paginators compile for
generic clients in `orchestrator` mode

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
parent 56766816
Loading
Loading
Loading
Loading
+14 −17
Original line number Diff line number Diff line
@@ -458,8 +458,6 @@ class FluentClientGenerator(
                )
            }

            // TODO(enableNewSmithyRuntime): Port paginators to the orchestrator
            if (smithyRuntimeMode.generateMiddleware) {
            PaginatorGenerator.paginatorType(codegenContext, generics, operation, retryClassifier)
                ?.also { paginatorType ->
                    rustTemplate(
@@ -474,7 +472,6 @@ class FluentClientGenerator(
                        "Paginator" to paginatorType,
                    )
                }
            }
            writeCustomizations(
                customizations,
                FluentClientSection.FluentBuilderImpl(
+26 −1
Original line number Diff line number Diff line
@@ -6,9 +6,12 @@
package software.amazon.smithy.rust.codegen.client.smithy.generators

import org.junit.jupiter.api.Test
import software.amazon.smithy.model.node.ObjectNode
import software.amazon.smithy.model.node.StringNode
import software.amazon.smithy.rust.codegen.client.testutil.clientIntegrationTest
import software.amazon.smithy.rust.codegen.core.rustlang.Attribute
import software.amazon.smithy.rust.codegen.core.rustlang.rust
import software.amazon.smithy.rust.codegen.core.testutil.IntegrationTestParams
import software.amazon.smithy.rust.codegen.core.testutil.asSmithyModel
import software.amazon.smithy.rust.codegen.core.testutil.integrationTest

@@ -67,8 +70,9 @@ internal class PaginatorGeneratorTest {
        }
    """.asSmithyModel()

    // TODO(enableNewSmithyRuntime): Remove this middleware test when launching
    @Test
    fun `generate paginators that compile`() {
    fun `generate paginators that compile with middleware`() {
        clientIntegrationTest(model) { clientCodegenContext, rustCrate ->
            rustCrate.integrationTest("paginators_generated") {
                Attribute.AllowUnusedImports.render(this)
@@ -76,4 +80,25 @@ internal class PaginatorGeneratorTest {
            }
        }
    }

    private fun enableNewSmithyRuntime(): ObjectNode = ObjectNode.objectNodeBuilder()
        .withMember(
            "codegen",
            ObjectNode.objectNodeBuilder()
                .withMember("enableNewSmithyRuntime", StringNode.from("orchestrator")).build(),
        )
        .build()

    @Test
    fun `generate paginators that compile`() {
        clientIntegrationTest(
            model,
            params = IntegrationTestParams(additionalSettings = enableNewSmithyRuntime()),
        ) { clientCodegenContext, rustCrate ->
            rustCrate.integrationTest("paginators_generated") {
                Attribute.AllowUnusedImports.render(this)
                rust("use ${clientCodegenContext.moduleUseName()}::operation::paginated_list::paginator::PaginatedListPaginator;")
            }
        }
    }
}