From 5eb8d4cef284fa59312355eb4f3a204e19dbd175 Mon Sep 17 00:00:00 2001 From: david-perez Date: Tue, 18 Jan 2022 12:02:08 +0100 Subject: [PATCH] Filter protocol tests applied to errors depending on client or server (#1081) For `httpRequestTest`s and `httpResponseTest`s applied to operations, we're only generating the tests that apply to servers or clients. This commit does the same when `httpResponseTest` is applied to errors. --- .../smithy/generators/protocol/ServerProtocolTestGenerator.kt | 4 ++-- .../smithy/generators/protocol/ProtocolTestGenerator.kt | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/protocol/ServerProtocolTestGenerator.kt b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/protocol/ServerProtocolTestGenerator.kt index 4f4df441d..6f90dfcb1 100644 --- a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/protocol/ServerProtocolTestGenerator.kt +++ b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/protocol/ServerProtocolTestGenerator.kt @@ -92,9 +92,9 @@ class ServerProtocolTestGenerator( ?.getTestCasesFor(AppliesTo.SERVER).orEmpty().map { TestCase.RequestTest(it, inputShape) } val responseTests = operationShape.getTrait() ?.getTestCasesFor(AppliesTo.SERVER).orEmpty().map { TestCase.ResponseTest(it, outputShape) } - val errorTests = operationIndex.getErrors(operationShape).flatMap { error -> - val testCases = error.getTrait()?.testCases.orEmpty() + val testCases = error.getTrait() + ?.getTestCasesFor(AppliesTo.SERVER).orEmpty() testCases.map { TestCase.ResponseTest(it, error) } } val allTests: List = (requestTests + responseTests + errorTests).filterMatching().fixBroken() diff --git a/codegen/src/main/kotlin/software/amazon/smithy/rust/codegen/smithy/generators/protocol/ProtocolTestGenerator.kt b/codegen/src/main/kotlin/software/amazon/smithy/rust/codegen/smithy/generators/protocol/ProtocolTestGenerator.kt index a54da64a7..22266bcc8 100644 --- a/codegen/src/main/kotlin/software/amazon/smithy/rust/codegen/smithy/generators/protocol/ProtocolTestGenerator.kt +++ b/codegen/src/main/kotlin/software/amazon/smithy/rust/codegen/smithy/generators/protocol/ProtocolTestGenerator.kt @@ -97,9 +97,9 @@ class ProtocolTestGenerator( ?.getTestCasesFor(AppliesTo.CLIENT).orEmpty().map { TestCase.RequestTest(it) } val responseTests = operationShape.getTrait() ?.getTestCasesFor(AppliesTo.CLIENT).orEmpty().map { TestCase.ResponseTest(it, outputShape) } - val errorTests = operationIndex.getErrors(operationShape).flatMap { error -> - val testCases = error.getTrait()?.testCases.orEmpty() + val testCases = error.getTrait() + ?.getTestCasesFor(AppliesTo.CLIENT).orEmpty() testCases.map { TestCase.ResponseTest(it, error) } } val allTests: List = (requestTests + responseTests + errorTests).filterMatching() -- GitLab