Erich Buri
03/20/2023, 10:21 PMaddInteraction() method (willRespondWith).
But the resulting pact-json file would have the expressiveness to do what I want.
I can't find a matcher that would yield the matchingRules that I'm looking for.
As an example:
Instead of
"$.body.angebote.CLASSIC.angebotStatusFachlich": {
"match": "type"
},
"$.body.angebote.COMFORT.angebotStatusFachlich": {
"match": "type"
},
I would like it to generate:
"$.body.angebote.*.angebotStatusFachlich": {
"match": "type"
},
Another example:
merkmale: {
DOMIZILLAND_VN: {
art: 400054,
code: 40,
},
MERKMAL_PARTNERART_VN: {
art: 432,
code: 433,
},
},
=> The keys will vary (DOMIZILLAND_VN, MERKMAL_PARTNERART_VN), so I would like to be able to generate rules like:
"$.body.merkmale.*.code": {
"match": "type"
},
We're currently using Pact 9.x - anything in there that would allow me to write the pact-test in a spec-File that will actually produce matching rules with wildcards? Manually writing the pact-files is not really maintainable.
Would there be a solution in 10.x?
I saw on github discussions about eachKey-Matchers and I think that goes in the right direction, but I could not find that in the API for 9.x
(I read that this kind of API is supposedly bad design, but it works really good with JavaScript/TS Frontends and it is now what it is.)
Any help is appreciated.Matt (pactflow.io / pact-js / pact-go)
Matt (pactflow.io / pact-js / pact-go)
Erich Buri
03/20/2023, 10:24 PMeachValueLike() sounds exactly like the thing I need.Erich Buri
03/20/2023, 10:25 PMeachValueLike only with v3 Pact Files?Erich Buri
03/20/2023, 10:26 PMTimothy Jones
03/21/2023, 1:19 AMCan I use 10.x to generate v2-Pact-Files?Yes, but not if you use the
eachValueLike matcher.Erich Buri
03/22/2023, 6:43 PMeachKeyLike (could not find an eachValueLike except in a github-issue discussion)
It seems like the resulting matchingRules are broken. Is that a know issue?
I have the following Interaction:
await provider
.given('Server is healthy')
.uponReceiving('a request to create a new Angebot for Rechtsschutzversicherung-Unternehmen')
.withRequest({
method: 'POST',
path: `/vvn/kaufen-b2c/rest/angebote/rechtsschutzversicherung-unternehmen/v2/neugeschaeft`,
query: { forceCaptcha: 'false' },
headers: {
'x-user-id': 'Z123456',
'x-caller': 'pact-verification',
'x-fall-id': fallid,
'Content-Type': 'application/json',
},
body: angeboteErstellenNeugeschaeftRsvUnternehmen as any,
})
.willRespondWith({
status: 200,
headers: {
'Content-Type': 'application/json',
},
body: {
angebote: MatchersV3.eachKeyLike('CLASSIC', {
angebotStatusTechnisch: MatchersV3.string('TECHNISCH_KONSISTENT'),
}),
},
});
});
Resulting matchingRules :
"matchingRules": {
"body": {
"$.angebote": {
"combine": "AND",
"matchers": [
{
"match": "values"
}
]
},
"$.angebote.*.*": {
"combine": "AND",
"matchers": [
{
"match": "type"
}
]
}
},
"header": {}
},
$.angebote.*.* is wrong. It should IMHO be:`$.angebote.*.angebotStatusTechnisch`Erich Buri
03/22/2023, 6:45 PMErich Buri
03/22/2023, 6:45 PMErich Buri
03/22/2023, 6:46 PMErich Buri
03/22/2023, 7:52 PM"generators": {
"body": {
"$.angebote.*.*.*": {
"type": "Uuid"
},
"$.angebote.*.*.*.*.*": {
"max": 10,
"min": 0,
"type": "RandomInt"
},
"$.angebote.*.*.*[*].*": {
"type": "Uuid"
},