-
Notifications
You must be signed in to change notification settings - Fork 21
Open
Description
Generator MockServerURL is used like this:
{
'pact:matcher:type': 'regex',
'pact:generator:type': 'MockServerURL',
regex: '.*(\\/example/path)$',
value: 'http://localhost:8080/example/path',
example: 'http://localhost:8080/example/path',
}Mock Server support this generator (obviously from its name), so Consumer's contract test passed.
But Stub Server doesn't support this generator, so Consumer's integration test failed.
I think:
- This is a bug, and Stub Server should support this generator (because it support other generators, at least I tested with
RandomInt) - Should we rename
MockServerURLto something else that say that Stub Server support it too? I don't have suggestion, naming is hard.
Here are some additional information:
- Demo project https://github.com/tienvx/test-mock-server-url-generator
- Slack's discussion https://pact-foundation.slack.com/archives/CA2S7E6KC/p1682530823430519
- Sequence diagram from what I understand + expect what to happen
Pact file from the above demo project
In case you don't want to run the demo project to see the contract file
{
"consumer": {
"name": "MyConsumer"
},
"interactions": [
{
"description": "a request for all urls",
"key": "285dde1d2816ddad",
"pending": false,
"providerStates": [
{
"name": "I have a list of urls"
}
],
"request": {
"headers": {
"Accept": [
"application/json"
]
},
"method": "GET",
"path": "/urls"
},
"response": {
"body": {
"content": {
"urls": [
{
"url": "http://localhost:8080/example/path"
}
]
},
"contentType": "application/json",
"encoded": false
},
"generators": {
"body": {
"$.urls[*].url": {
"example": "http://localhost:8080/example/path",
"regex": ".*(\\/example/path)$",
"type": "MockServerURL"
}
}
},
"headers": {
"Content-Type": [
"application/json"
]
},
"matchingRules": {
"body": {
"$.urls": {
"combine": "AND",
"matchers": [
{
"match": "type",
"min": 1
}
]
},
"$.urls[*].url": {
"combine": "AND",
"matchers": [
{
"match": "regex",
"regex": ".*(\\/example/path)$"
}
]
}
},
"header": {}
},
"status": 200
},
"type": "Synchronous/HTTP"
},
{
"description": "a request the url http://provider.com/example/path",
"key": "7824381c6cca0583",
"pending": false,
"providerStates": [
{
"name": "I have a url http://provider.com/example/path"
}
],
"request": {
"headers": {
"Accept": [
"application/json"
]
},
"method": "GET",
"path": "/example/path"
},
"response": {
"body": {
"content": {
"key": "value"
},
"contentType": "application/json",
"encoded": false
},
"headers": {
"Content-Type": [
"application/json"
]
},
"matchingRules": {
"body": {
"$.key": {
"combine": "AND",
"matchers": [
{
"match": "type"
}
]
}
},
"header": {}
},
"status": 200
},
"type": "Synchronous/HTTP"
}
],
"metadata": {
"pact-js": {
"version": "11.0.2"
},
"pactRust": {
"ffi": "0.4.0",
"models": "1.0.4"
},
"pactSpecification": {
"version": "4.0"
}
},
"provider": {
"name": "MyProvider"
}
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels