Skip to content
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

chore: Add aws_json error code tests #1798

Merged
merged 3 commits into from
Oct 23, 2024
Merged

Conversation

jbelkins
Copy link
Contributor

@jbelkins jbelkins commented Oct 22, 2024

Description of changes

  • Adds tests to verify that the AWSJSON base error decodes error codes as required by the Smithy spec.
  • Simplifies tests for RestJSON base error to concentrate on just testing the base error and not generated code.

Note that are no actual code changes in this PR, only tests. Upon close examination, the logic for error codes is correct but it was untested.

New/existing dependencies impact assessment, if applicable

No new dependencies were added to this change.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@jbelkins jbelkins changed the title fix: Strip prefix & suffix from aws_json error codes fix: Add aws_json error code tests Oct 22, 2024
@jbelkins jbelkins changed the title fix: Add aws_json error code tests chore: Add aws_json error code tests Oct 22, 2024
"aws.protocoltests.restjson#FooError:http://internal.amazon.com/coral/com.amazon.coral.validate/"
]

// MARK: - error code decoding & sanitization
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests are added below to ensure that error code can be decoded no matter which of the allowed places it is located.

) else {
XCTFail("Something is wrong with the created http response")
return
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic above is extracted to a helper method, defined below.

}

func testSanitizeErrorName() async throws {
let errorCodes = [
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These error codes match the ones used for AWS JSON

@jbelkins jbelkins marked this pull request as ready for review October 22, 2024 18:12
@jbelkins jbelkins merged commit 17d6f19 into main Oct 23, 2024
29 checks passed
@jbelkins jbelkins deleted the jbe/aws_json_error_code_fix branch October 23, 2024 15:27
jbelkins added a commit that referenced this pull request Oct 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants