question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

contract_tests: contract_create_read_success and primaryIdentifiers in responses

See original GitHub issue

When 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:open
  • Created 2 years ago
  • Comments:20 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
benbridtscommented, Apr 13, 2021

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?

0reactions
SHxKMcommented, Apr 18, 2021

Thanks @benbridts.

I’m keeping this open as nested primaryIdentifiers seem to fail the tests, which shouldn’t happen.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found