Skip to content

Commit

Permalink
Empty payload structure in tests (#2328)
Browse files Browse the repository at this point in the history
* Empty payload structure in tests

Signed-off-by: Daniele Ahmed <[email protected]>

* Update ServerProtocolTestGenerator

Signed-off-by: Daniele Ahmed <[email protected]>

* Update ServerProtocolTestGenerator

Signed-off-by: Daniele Ahmed <[email protected]>

---------

Signed-off-by: Daniele Ahmed <[email protected]>
Co-authored-by: Zelda Hessler <[email protected]>
  • Loading branch information
82marbag and Velfi authored Mar 29, 2023
1 parent 48bd719 commit 9a77a8c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import software.amazon.smithy.model.shapes.TimestampShape
import software.amazon.smithy.model.shapes.UnionShape
import software.amazon.smithy.model.traits.EnumTrait
import software.amazon.smithy.model.traits.HttpHeaderTrait
import software.amazon.smithy.model.traits.HttpPayloadTrait
import software.amazon.smithy.model.traits.HttpPrefixHeadersTrait
import software.amazon.smithy.model.traits.StreamingTrait
import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency
Expand Down Expand Up @@ -361,6 +362,16 @@ open class Instantiator(
renderMemberHelper(memberShape, value)
}

shape.allMembers.entries
.firstOrNull {
it.value.hasTrait<HttpPayloadTrait>() &&
!data.members.containsKey(Node.from(it.key)) &&
model.expectShape(it.value.target) is StructureShape
}
?.let {
renderMemberHelper(it.value, fillDefaultValue(model.expectShape(it.value.target)))
}

writer.rust(".build()")
if (builderKindBehavior.hasFallibleBuilder(shape)) {
writer.rust(".unwrap()")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -762,11 +762,6 @@ class ServerProtocolTestGenerator(
private const val RestJson = "aws.protocoltests.restjson#RestJson"
private const val RestJsonValidation = "aws.protocoltests.restjson.validation#RestJsonValidation"
private val ExpectFail: Set<FailingTest> = setOf(
// Pending resolution from the Smithy team, see https://github.com/awslabs/smithy/issues/1068.
FailingTest(RestJson, "RestJsonHttpWithHeadersButNoPayload", TestType.Request),

FailingTest(RestJson, "RestJsonHttpWithEmptyStructurePayload", TestType.Request),

// Endpoint trait is not implemented yet, see https://github.com/awslabs/smithy-rs/issues/950.
FailingTest(RestJson, "RestJsonEndpointTrait", TestType.Request),
FailingTest(RestJson, "RestJsonEndpointTraitWithHostLabel", TestType.Request),
Expand Down

0 comments on commit 9a77a8c

Please sign in to comment.