contract_tests: contract_create_read_success and primaryIdentifiers in responses
See original GitHub issueWhen a customer wants to create a our resource, he sends a request like so:
{
"ourObj": {
"someProp": "someValue"
}
}
And our API, upon successful creation, will return the following:
{
"ourObj": {
"someProp": "someValue",
"id": "ourJustGeneratedObjId"
}
}
It seems that there is no way at all to pass the contract-tests with this schema. Passing a hard-coded value for ourObj.id
does not make sense, as the delete test will fail.
I’ve worked around the contract_create_delete
failure by copying ourObj.id
to another property in the schema:
{
"CfnId": "ourJustGeneratedObjId",
"ourObj": {
"someProp": "someValue",
"id": "ourJustGeneratedObjId"
}
}
CfnId
is set as the primaryIdentifier
.
This way, the model sent in the request is returned back in the response - none have the ourObj.id
. However, our customers may be relying on the existence of this id
inside ourObj
.
What can be done about this?
Issue Analytics
- State:
- Created 2 years ago
- Comments:20 (9 by maintainers)
Top Results From Across the Web
Introduction To Pact Contract Testing With Examples
Contract testing is a method to verify integration between two applications independently in order to test what has been passed and see if...
Read more >Contract tests - CloudFormation Command Line Interface
The CloudFormation CLI performs this contract test for resources with create-only primary identifiers. contract_delete_update.
Read more >Getting Started | Consumer Driven Contracts - Spring
This test class will load the stubs of the contract producer service and make sure that the integration to the service is aligned...
Read more >Contract Tests vs Functional Tests | Pact Docs
Contract tests focus on the messages that flow between a consumer and provider, while functional tests also ensure that the correct side ...
Read more >Writing Contract Tests with Pact in Spring Boot - kreuzwerker
The expected response contains the expected JSON but only the parts that are actually relevant for the consumer. Example participants. We will ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Can you share a snippet of your schema?
Is your issue that
id
is a nested property, or that you need it to be readonly?Thanks @benbridts.
I’m keeping this open as nested
primaryIdentifier
s seem to fail the tests, which shouldn’t happen.