Skip to content

Commit

Permalink
Update protocol test case generation (#275)
Browse files Browse the repository at this point in the history
  • Loading branch information
kstich authored Feb 23, 2021
1 parent 8ea5676 commit 62f7953
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
import software.amazon.smithy.model.traits.HttpPrefixHeadersTrait;
import software.amazon.smithy.model.traits.IdempotencyTokenTrait;
import software.amazon.smithy.model.traits.StreamingTrait;
import software.amazon.smithy.protocoltests.traits.AppliesTo;
import software.amazon.smithy.protocoltests.traits.HttpMessageTestCase;
import software.amazon.smithy.protocoltests.traits.HttpRequestTestCase;
import software.amazon.smithy.protocoltests.traits.HttpRequestTestsTrait;
Expand Down Expand Up @@ -118,21 +119,21 @@ public void run() {
if (!operation.hasTag("server-only")) {
// 1. Generate test cases for each request.
operation.getTrait(HttpRequestTestsTrait.class).ifPresent(trait -> {
for (HttpRequestTestCase testCase : trait.getTestCases()) {
for (HttpRequestTestCase testCase : trait.getTestCasesFor(AppliesTo.CLIENT)) {
onlyIfProtocolMatches(testCase, () -> generateRequestTest(operation, testCase));
}
});
// 2. Generate test cases for each response.
operation.getTrait(HttpResponseTestsTrait.class).ifPresent(trait -> {
for (HttpResponseTestCase testCase : trait.getTestCases()) {
for (HttpResponseTestCase testCase : trait.getTestCasesFor(AppliesTo.CLIENT)) {
onlyIfProtocolMatches(testCase, () -> generateResponseTest(operation, testCase));
}
});
// 3. Generate test cases for each error on each operation.
for (StructureShape error : operationIndex.getErrors(operation)) {
if (!error.hasTag("server-only")) {
error.getTrait(HttpResponseTestsTrait.class).ifPresent(trait -> {
for (HttpResponseTestCase testCase : trait.getTestCases()) {
for (HttpResponseTestCase testCase : trait.getTestCasesFor(AppliesTo.CLIENT)) {
onlyIfProtocolMatches(testCase,
() -> generateErrorResponseTest(operation, error, testCase));
}
Expand Down

0 comments on commit 62f7953

Please sign in to comment.