-
Notifications
You must be signed in to change notification settings - Fork 193
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
Test httpRequestTests
against actual Services
#1708
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
.../amazon/smithy/rust/codegen/server/smithy/generators/protocol/ServerProtocolTestGenerator.kt
Outdated
Show resolved
Hide resolved
.../amazon/smithy/rust/codegen/server/smithy/generators/protocol/ServerProtocolTestGenerator.kt
Outdated
Show resolved
Hide resolved
.../amazon/smithy/rust/codegen/server/smithy/generators/protocol/ServerProtocolTestGenerator.kt
Outdated
Show resolved
Hide resolved
.../amazon/smithy/rust/codegen/server/smithy/generators/protocol/ServerProtocolTestGenerator.kt
Outdated
Show resolved
Hide resolved
.../amazon/smithy/rust/codegen/server/smithy/generators/protocol/ServerProtocolTestGenerator.kt
Outdated
Show resolved
Hide resolved
codegen/src/main/kotlin/software/amazon/smithy/rust/codegen/smithy/generators/Instantiator.kt
Outdated
Show resolved
Hide resolved
...en/src/test/kotlin/software/amazon/smithy/rust/codegen/smithy/generators/InstantiatorTest.kt
Outdated
Show resolved
Hide resolved
...en/src/test/kotlin/software/amazon/smithy/rust/codegen/smithy/generators/InstantiatorTest.kt
Outdated
Show resolved
Hide resolved
...en/src/test/kotlin/software/amazon/smithy/rust/codegen/smithy/generators/InstantiatorTest.kt
Outdated
Show resolved
Hide resolved
...en/src/test/kotlin/software/amazon/smithy/rust/codegen/smithy/generators/InstantiatorTest.kt
Outdated
Show resolved
Hide resolved
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
Signed-off-by: Weihang Lo <weihanglo@users.noreply.github.com>
Signed-off-by: Weihang Lo <weihanglo@users.noreply.github.com>
Signed-off-by: Weihang Lo <weihanglo@users.noreply.github.com>
Signed-off-by: Weihang Lo <weihanglo@users.noreply.github.com>
Co-authored-by: david-perez <d@vidp.dev>
Signed-off-by: Weihang Lo <weihanglo@users.noreply.github.com>
Signed-off-by: Weihang Lo <weihanglo@users.noreply.github.com>
3ed0ad4
to
4212818
Compare
This comment was marked as outdated.
This comment was marked as outdated.
Most of the issues have been resolved. I marked minor refactoring comments as |
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
Missing `X-Amz-Target` in response header
This comment was marked as outdated.
This comment was marked as outdated.
A new generated diff is ready to view.
A new doc preview is ready to view. |
val variant = data.members.iterator().next() | ||
val memberName = variant.key.value | ||
|
||
val variant = if (ctx.defaultsForRequiredFields && data.members.isEmpty()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It'd be nice to destructure here, maybe something like this?
val variant = if (ctx.defaultsForRequiredFields && data.members.isEmpty()) { | |
val (memberName, memberDefaultValue) = if (ctx.defaultsForRequiredFields && data.members.isEmpty()) { |
/** | ||
* Returns a default value for a shape. | ||
* | ||
* Warning: this method does not take into account any constraint traits attached to the shape. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It'd be nice if these docs could include some examples of what this function does. You could take one of your tests and convert it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Client changes look good to me!
) | ||
|
||
companion object { | ||
fun defaultContext() = Ctx(lowercaseMapKeys = false, streaming = false, builder = false, defaultsForRequiredFields = false) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is fine, but it's a lot more flexible if you just set the defaults using default args directly on Ctx
, since then you can override one of the defaults easily. For example, if you only wanted to override streaming: Ctx(streaming = true)
.
Since this PR somehow blocks #1693 I'll merge it as is and do some follow-ups. Thank you all for the reviews! |
This comment was marked as outdated.
This comment was marked as outdated.
A new generated diff is ready to view.
A new doc preview is ready to view. |
Motivation and Context
#1212
Description
Before this PR, we constructs
Request
manually to test against@httpRequestTests
of protocol compliances tests. After this PR, we construct a tower service and turn it into a Router.That makes our test cases
method
fieldThe implementation is quite simple. We add a helper module
renderTestHelper
which containsfn validate_request(…)
sharing the logic of building aRouter
and exercise against each@httpRequestTests
. We then put the assertion logic inside each operation handler. Some type coercions are needed insidefn create_operation_registry_builder(…)
since we want a builder with blanket operations at first, and then set the actual operation handler for each test case.Testing
Run
./gradlew codegen-server-test:test
and see if all protocol tests are passed.Checklist
CHANGELOG.next.toml
if I made changes to the smithy-rs codegen or runtime cratesCHANGELOG.next.toml
if I made changes to the AWS SDK, generated SDK code, or SDK runtime cratesBy submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.