Skip to content

Commit 62f7953

Browse files
authored
Update protocol test case generation (#275)
1 parent 8ea5676 commit 62f7953

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/HttpProtocolTestGenerator.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
import software.amazon.smithy.model.traits.HttpPrefixHeadersTrait;
5353
import software.amazon.smithy.model.traits.IdempotencyTokenTrait;
5454
import software.amazon.smithy.model.traits.StreamingTrait;
55+
import software.amazon.smithy.protocoltests.traits.AppliesTo;
5556
import software.amazon.smithy.protocoltests.traits.HttpMessageTestCase;
5657
import software.amazon.smithy.protocoltests.traits.HttpRequestTestCase;
5758
import software.amazon.smithy.protocoltests.traits.HttpRequestTestsTrait;
@@ -118,21 +119,21 @@ public void run() {
118119
if (!operation.hasTag("server-only")) {
119120
// 1. Generate test cases for each request.
120121
operation.getTrait(HttpRequestTestsTrait.class).ifPresent(trait -> {
121-
for (HttpRequestTestCase testCase : trait.getTestCases()) {
122+
for (HttpRequestTestCase testCase : trait.getTestCasesFor(AppliesTo.CLIENT)) {
122123
onlyIfProtocolMatches(testCase, () -> generateRequestTest(operation, testCase));
123124
}
124125
});
125126
// 2. Generate test cases for each response.
126127
operation.getTrait(HttpResponseTestsTrait.class).ifPresent(trait -> {
127-
for (HttpResponseTestCase testCase : trait.getTestCases()) {
128+
for (HttpResponseTestCase testCase : trait.getTestCasesFor(AppliesTo.CLIENT)) {
128129
onlyIfProtocolMatches(testCase, () -> generateResponseTest(operation, testCase));
129130
}
130131
});
131132
// 3. Generate test cases for each error on each operation.
132133
for (StructureShape error : operationIndex.getErrors(operation)) {
133134
if (!error.hasTag("server-only")) {
134135
error.getTrait(HttpResponseTestsTrait.class).ifPresent(trait -> {
135-
for (HttpResponseTestCase testCase : trait.getTestCases()) {
136+
for (HttpResponseTestCase testCase : trait.getTestCasesFor(AppliesTo.CLIENT)) {
136137
onlyIfProtocolMatches(testCase,
137138
() -> generateErrorResponseTest(operation, error, testCase));
138139
}

0 commit comments

Comments
 (0)