Skip to content

Commit 440f312

Browse files
committed
Skip generating tests marked server-only
1 parent ebc70f9 commit 440f312

File tree

1 file changed

+21
-16
lines changed

1 file changed

+21
-16
lines changed

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

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -111,25 +111,30 @@ public void run() {
111111

112112
// Use a TreeSet to have a fixed ordering of tests.
113113
for (OperationShape operation : new TreeSet<>(topDownIndex.getContainedOperations(service))) {
114-
// 1. Generate test cases for each request.
115-
operation.getTrait(HttpRequestTestsTrait.class).ifPresent(trait -> {
116-
for (HttpRequestTestCase testCase : trait.getTestCases()) {
117-
onlyIfProtocolMatches(testCase, () -> generateRequestTest(operation, testCase));
118-
}
119-
});
120-
// 2. Generate test cases for each response.
121-
operation.getTrait(HttpResponseTestsTrait.class).ifPresent(trait -> {
122-
for (HttpResponseTestCase testCase : trait.getTestCases()) {
123-
onlyIfProtocolMatches(testCase, () -> generateResponseTest(operation, testCase));
124-
}
125-
});
126-
// 3. Generate test cases for each error on each operation.
127-
for (StructureShape error : operationIndex.getErrors(operation)) {
128-
error.getTrait(HttpResponseTestsTrait.class).ifPresent(trait -> {
114+
if (!operation.hasTag("server-only")) {
115+
// 1. Generate test cases for each request.
116+
operation.getTrait(HttpRequestTestsTrait.class).ifPresent(trait -> {
117+
for (HttpRequestTestCase testCase : trait.getTestCases()) {
118+
onlyIfProtocolMatches(testCase, () -> generateRequestTest(operation, testCase));
119+
}
120+
});
121+
// 2. Generate test cases for each response.
122+
operation.getTrait(HttpResponseTestsTrait.class).ifPresent(trait -> {
129123
for (HttpResponseTestCase testCase : trait.getTestCases()) {
130-
onlyIfProtocolMatches(testCase, () -> generateErrorResponseTest(operation, error, testCase));
124+
onlyIfProtocolMatches(testCase, () -> generateResponseTest(operation, testCase));
131125
}
132126
});
127+
// 3. Generate test cases for each error on each operation.
128+
for (StructureShape error : operationIndex.getErrors(operation)) {
129+
if (!error.hasTag("server-only")) {
130+
error.getTrait(HttpResponseTestsTrait.class).ifPresent(trait -> {
131+
for (HttpResponseTestCase testCase : trait.getTestCases()) {
132+
onlyIfProtocolMatches(testCase,
133+
() -> generateErrorResponseTest(operation, error, testCase));
134+
}
135+
});
136+
}
137+
}
133138
}
134139
}
135140

0 commit comments

Comments
 (0)