Skip to content

chore: support programmatically generating and skipping protocol tests #2506

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion codegen/protocol-test-codegen/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import software.amazon.smithy.gradle.tasks.SmithyBuild

plugins {
id("software.amazon.smithy") version "0.5.2"
id("software.amazon.smithy") version "0.5.3"
}

dependencies {
Expand Down
2 changes: 1 addition & 1 deletion codegen/sdk-codegen/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import software.amazon.smithy.model.node.Node
import software.amazon.smithy.gradle.tasks.SmithyBuild

plugins {
id("software.amazon.smithy") version "0.5.2"
id("software.amazon.smithy") version "0.5.3"
}

dependencies {
Expand Down
1 change: 1 addition & 0 deletions codegen/smithy-aws-typescript-codegen/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@ dependencies {
api("software.amazon.smithy:smithy-aws-traits:[1.8.0, 1.9.0[")
api("software.amazon.smithy:smithy-waiters:[1.8.0, 1.9.0[")
api("software.amazon.smithy:smithy-aws-iam-traits:[1.8.0, 1.9.0[")
api("software.amazon.smithy:smithy-protocol-test-traits:[1.8.0, 1.9.0[")
api("software.amazon.smithy.typescript:smithy-typescript-codegen:0.3.0")
}
Original file line number Diff line number Diff line change
Expand Up @@ -167,4 +167,9 @@ protected void deserializeOutputDocument(
writer.write("contents = $L;",
outputStructure.accept(new XmlMemberDeserVisitor(context, "data", Format.DATE_TIME)));
}

@Override
public void generateProtocolTests(GenerationContext context) {
AwsProtocolUtils.generateProtocolTests(this, context);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,12 @@
import software.amazon.smithy.model.traits.TimestampFormatTrait;
import software.amazon.smithy.model.traits.TimestampFormatTrait.Format;
import software.amazon.smithy.model.traits.XmlNamespaceTrait;
import software.amazon.smithy.protocoltests.traits.HttpMessageTestCase;
import software.amazon.smithy.typescript.codegen.HttpProtocolTestGenerator;
import software.amazon.smithy.typescript.codegen.TypeScriptSettings;
import software.amazon.smithy.typescript.codegen.TypeScriptWriter;
import software.amazon.smithy.typescript.codegen.integration.HttpProtocolGeneratorUtils;
import software.amazon.smithy.typescript.codegen.integration.ProtocolGenerator;
import software.amazon.smithy.typescript.codegen.integration.ProtocolGenerator.GenerationContext;
import software.amazon.smithy.utils.SmithyInternalApi;

Expand Down Expand Up @@ -274,4 +278,21 @@ static String getInputTimestampValueProvider(
TimestampFormatTrait.Format format = httpIndex.determineTimestampFormat(memberShape, DOCUMENT, defaultFormat);
return HttpProtocolGeneratorUtils.getTimestampInputParam(context, inputLocation, memberShape, format);
}

static void generateProtocolTests(ProtocolGenerator generator, GenerationContext context) {
new HttpProtocolTestGenerator(context, generator, AwsProtocolUtils::filterProtocolTests).run();
}

private static boolean filterProtocolTests(
ServiceShape service,
OperationShape operation,
HttpMessageTestCase testCase,
TypeScriptSettings settings
) {
// TODO: Consume AWSQueryError trait as a follow-up.
if (testCase.getId().equals("QueryCustomizedError")) {
return true;
}
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -168,4 +168,9 @@ protected void deserializeOutputDocument(
writer.write("contents = $L;",
outputStructure.accept(new XmlMemberDeserVisitor(context, dataSource, Format.DATE_TIME)));
}

@Override
public void generateProtocolTests(GenerationContext context) {
AwsProtocolUtils.generateProtocolTests(this, context);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -350,4 +350,9 @@ private void deserializeDocumentBody(
});
}
}

@Override
public void generateProtocolTests(GenerationContext context) {
AwsProtocolUtils.generateProtocolTests(this, context);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -141,4 +141,9 @@ protected void deserializeOutputDocument(
private DocumentMemberDeserVisitor getMemberDeserVisitor(GenerationContext context, String dataSource) {
return new JsonMemberDeserVisitor(context, dataSource, getDocumentTimestampFormat());
}

@Override
public void generateProtocolTests(GenerationContext context) {
AwsProtocolUtils.generateProtocolTests(this, context);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -341,4 +341,9 @@ protected void readPayload(
private DocumentMemberDeserVisitor getMemberDeserVisitor(GenerationContext context, String dataSource) {
return new JsonMemberDeserVisitor(context, dataSource, getDocumentTimestampFormat());
}

@Override
public void generateProtocolTests(GenerationContext context) {
AwsProtocolUtils.generateProtocolTests(this, context);
}
}
2 changes: 0 additions & 2 deletions protocol_tests/aws-query/tests/functional/awsquery.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -548,8 +548,6 @@ it("QueryInvalidGreetingError:Error:GreetingWithErrors", async () => {
/**
* Parses customized XML errors
*/
// Manually skipping to unblock smithy-1.8.x update.
// TODO: Consume AWSQueryError trait as a follow-up.
it.skip("QueryCustomizedError:Error:GreetingWithErrors", async () => {
const client = new QueryProtocolClient({
...clientParams,
Expand Down