Skip to content

Commit

Permalink
fix: pact found bug in pact example tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mefellows committed Jun 7, 2021
1 parent 7e89481 commit 4525047
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 17 deletions.
4 changes: 2 additions & 2 deletions examples/consumer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func TestConsumerV2(t *testing.T) {
WillRespondWith(200).
WithHeader("Content-Type", Regex("application/json", "application\\/json")).
WithJSONBody(Map{
"dateTime": Regex("2020-01-01", "[0-9\\-]+"),
"datetime": Regex("2020-01-01", "[0-9\\-]+"),
"name": S("Billy"),
"lastName": S("Sampson"),
"itemsMin": ArrayMinLike("thereshouldbe3ofthese", 3),
Expand Down Expand Up @@ -125,7 +125,7 @@ func TestConsumerV3(t *testing.T) {
WillRespondWith(200).
WithHeader("Content-Type", S("application/json")).
WithJSONBody(Map{
"dateTime": Regex("2020-01-01", "[0-9\\-]+"),
"datetime": Regex("2020-01-01", "[0-9\\-]+"),
"name": S("Billy"),
"lastName": S("Sampson"),
"superstring": Includes("foo"),
Expand Down
12 changes: 6 additions & 6 deletions examples/pacts/V2Consumer-V2Provider.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@
"$.header.Authorization": {
"match": "type"
},
"$.header.Content-Type": {
"match": "regex",
"regex": "application\\/json"
},
"$.path": {
"match": "regex",
"regex": "\\/foo.*"
Expand All @@ -60,7 +56,7 @@
},
"response": {
"body": {
"dateTime": "2020-01-01",
"datetime": "2020-01-01",
"itemsMin": [
"thereshouldbe3ofthese",
"thereshouldbe3ofthese",
Expand All @@ -73,13 +69,17 @@
"Content-Type": "application/json"
},
"matchingRules": {
"$.body.dateTime": {
"$.body.datetime": {
"match": "regex",
"regex": "[0-9\\-]+"
},
"$.body.itemsMin": {
"match": "type",
"min": 3
},
"$.header.Content-Type": {
"match": "regex",
"regex": "application\\/json"
}
},
"status": 200
Expand Down
31 changes: 27 additions & 4 deletions examples/pacts/V2ConsumerMatch-V2ProviderMatch.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@
"$.header.Authorization": {
"match": "type"
},
"$.header.Content-Type": {
"match": "regex",
"regex": "application\\/json"
},
"$.path": {
"match": "regex",
"regex": "\\/foo.*"
Expand All @@ -59,6 +55,33 @@
"query": "baz=bar&baz=bat&baz=baz"
},
"response": {
"body": {
"datetime": "2020-01-01'T'08:00:45,format=yyyy-MM-dd'T'HH:mm:ss,generator=datetime",
"id": 27,
"lastName": "Sampson",
"name": "Billy"
},
"headers": {
"Content-Type": "application/json"
},
"matchingRules": {
"$.body.datetime": {
"match": "type"
},
"$.body.id": {
"match": "type"
},
"$.body.lastName": {
"match": "type"
},
"$.body.name": {
"match": "type"
},
"$.header.Content-Type": {
"match": "regex",
"regex": "application\\/json"
}
},
"status": 200
}
}
Expand Down
7 changes: 4 additions & 3 deletions examples/pacts/V3Consumer-V3Provider.json
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@
"foo": "bar"
}
],
"dateTime": "2020-01-01",
"datetime": "2020-01-01",
"equality": "a thing",
"id": 12,
"itemsMin": [
Expand Down Expand Up @@ -222,7 +222,7 @@
}
]
},
"$.dateTime": {
"$.datetime": {
"combine": "AND",
"matchers": [
{
Expand Down Expand Up @@ -275,7 +275,8 @@
}
]
}
}
},
"header": {}
},
"status": 200
}
Expand Down
5 changes: 4 additions & 1 deletion examples/pacts/V3MessageConsumer-V3MessageProvider.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@
}
}
},
"metadata": {},
"metadata": {
"Content-Type": "application/json",
"contentType": "application/json"
},
"providerStates": [
{
"name": "User with id 127 exists",
Expand Down
2 changes: 1 addition & 1 deletion examples/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ func startServer() {
fmt.Fprintf(w, `
{
"accountBalance": 123.76,
"dateTime": "2020-01-01",
"datetime": "2020-01-01",
"equality": "a thing",
"id": 12,
"itemsMin": [
Expand Down

0 comments on commit 4525047

Please sign in to comment.