aws-cloudformation / aws-cloudformation/cloudformation-cli
contract_tests: contract_create_read_success and primaryIdentifiers in responses
- Vorherrschende Sprache
- Python
- Sterne
- 336
- Forks
- 172
- Ø Merge
- 3 T. 5 Min.
- Gemergte PRs (30 T.)
- 3
Beschreibung
When a customer wants to create a our resource, he sends a request like so:
```json
{
"ourObj": {
"someProp": "someValue"
}
}
```
And our API, upon successful creation, will return the following:
```json
{
"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:
```json
{
"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?
Beitragsleitfaden
Rechercherichtung
Beginne damit, die Tests contract_create_read_success und contract_create_delete zu lesen, und verfolge dann, wie primaryIdentifier und primaryIdentifiers im contract-test-Schema behandelt werden. Vergleiche die Request- und Response-Beispiele mit den Erwartungen des Delete-Tests und definiere das erwartete Verhalten für generierte Identifier, bevor du irgendetwas änderst.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- aws
- Bereich
- api, cloud, testing
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Muss geklärt werden
- Anfängerfreundlichkeit
- 25/100