Skip to content

Commit

Permalink
Merge commit 'eef31107a3c55d1fd33e7e1b916aa6fb131693ec'
Browse files Browse the repository at this point in the history
  • Loading branch information
rholshausen committed Aug 10, 2023
2 parents 4d81f84 + eef3110 commit 41e220d
Show file tree
Hide file tree
Showing 13 changed files with 447 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,21 +69,3 @@ Feature: V3 era Generators
| file: basic.json | boolean-generator.json |
When the request is prepared for use
Then the body value for "$.one" will have been replaced with a "boolean"

Scenario: Supports a Provider State generator
Given a request configured with the following generators:
| body | generators |
| file: basic.json | providerstate-generator.json |
And the generator test mode is set as "Provider"
When the request is prepared for use with a "providerState" context:
| { "id": 1000 } |
Then the body value for "$.one" will have been replaced with "1000"

Scenario: Supports a Mock server URL generator
Given a request configured with the following generators:
| body | generators |
| file: basic.json | mockserver-generator.json |
And the generator test mode is set as "Consumer"
When the request is prepared for use with a "mockServer" context:
| { "href": "http://somewhere.world" } |
Then the body value for "$.one" will have been replaced with "http://somewhere.world/a"
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
Feature: V4 era Generators

Scenario: Supports a Provider State generator
Given a request configured with the following generators:
| body | generators |
| file: basic.json | providerstate-generator.json |
And the generator test mode is set as "Provider"
When the request is prepared for use with a "providerState" context:
| { "id": 1000 } |
Then the body value for "$.one" will have been replaced with "1000"

Scenario: Supports a Mock server URL generator
Given a request configured with the following generators:
| body | generators |
| file: basic.json | mockserver-generator.json |
And the generator test mode is set as "Consumer"
When the request is prepared for use with a "mockServer" context:
| { "href": "http://somewhere.world" } |
Then the body value for "$.one" will have been replaced with "http://somewhere.world/a"

Scenario: Supports a simple UUID generator
Given a request configured with the following generators:
| body | generators |
| file: basic.json | uuid-generator-simple.json |
When the request is prepared for use
Then the body value for "$.one" will have been replaced with a "simple UUID"

Scenario: Supports a lower-case-hyphenated UUID generator
Given a request configured with the following generators:
| body | generators |
| file: basic.json | uuid-generator-lower-case-hyphenated.json |
When the request is prepared for use
Then the body value for "$.one" will have been replaced with a "lower-case-hyphenated UUID"

Scenario: Supports a upper-case-hyphenated UUID generator
Given a request configured with the following generators:
| body | generators |
| file: basic.json | uuid-generator-upper-case-hyphenated.json |
When the request is prepared for use
Then the body value for "$.one" will have been replaced with a "upper-case-hyphenated UUID"

Scenario: Supports a URN UUID generator
Given a request configured with the following generators:
| body | generators |
| file: basic.json | uuid-generator-urn.json |
When the request is prepared for use
Then the body value for "$.one" will have been replaced with a "URN UUID"
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,66 @@ Feature: V4 era Matching Rules
Then the comparison should NOT be OK
And the mismatches will contain a mismatch with error "$.one" -> "Expected '1.0' (String) to be a semantic version"
And the mismatches will contain a mismatch with error "$.two" -> "Expected '1.0abc' (String) to be a semantic version"

Scenario: Supports an EachKey matcher (positive case)
Given an expected request configured with the following:
| body | matching rules |
| file: basic.json | eachkey-matcher-v4.json |
And a request is received with the following:
| body |
| JSON: { "one": "a", "two": "b", "three": "c", "four": "d" } |
When the request is compared to the expected one
Then the comparison should be OK

Scenario: Supports an EachKey matcher (negative case)
Given an expected request configured with the following:
| body | matching rules |
| file: basic.json | eachkey-matcher-v4.json |
And a request is received with the following:
| body |
| JSON: { "one": "a", "two": "b", "three": "c", "100": "d" } |
When the request is compared to the expected one
Then the comparison should NOT be OK
And the mismatches will contain a mismatch with error "$[100]" -> "Expected '100' to match '[a-z]+"

Scenario: Supports an EachValue matcher (positive case)
Given an expected request configured with the following:
| body | matching rules |
| file: basic.json | eachvalue-matcher-v4.json |
And a request is received with the following:
| body |
| JSON: { "one": "a", "three": "b", "four": "c", "five": "d" } |
When the request is compared to the expected one
Then the comparison should be OK

Scenario: Supports a EachValue matcher (negative case)
Given an expected request configured with the following:
| body | matching rules |
| file: basic.json | eachvalue-matcher-v4.json |
And a request is received with the following:
| body |
| JSON: { "one": "", "two": "b", "three": "c", "four": "100" } |
When the request is compared to the expected one
Then the comparison should NOT be OK
And the mismatches will contain a mismatch with error "$.four" -> "Expected '100' to match '[a-z]+"

Scenario: Supports an ArrayContains matcher (positive case)
Given an expected request configured with the following:
| content type | body | matching rules |
| application/vnd.siren+json | file: siren.json | arraycontains-matcher-v4.json |
And a request is received with the following:
| content type | body |
| application/vnd.siren+json | file: siren2.json |
When the request is compared to the expected one
Then the comparison should be OK

Scenario: Supports a ArrayContains matcher (negative case)
Given an expected request configured with the following:
| content type | body | matching rules |
| application/vnd.siren+json | file: siren.json | arraycontains-matcher-v4.json |
And a request is received with the following:
| content type | body |
| application/vnd.siren+json | file: siren3.json |
When the request is compared to the expected one
Then the comparison should NOT be OK
And the mismatches will contain a mismatch with error "$.actions" -> "Variant at index 1 ({\"href\":\"http://api.x.io/orders/42/items\",\"method\":\"DELETE\",\"name\":\"delete-item\",\"title\":\"Delete Item\"}) was not found in the actual list"
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
{
"body": {
"$.actions": {
"combine": "AND",
"matchers": [
{
"match": "arrayContains",
"variants": [
{
"generators": {},
"index": 0,
"rules": {
"$.name": {
"combine": "AND",
"matchers": [
{
"match": "regex",
"regex": "add\\-item"
}
]
},
"$.method": {
"combine": "AND",
"matchers": [
{
"match": "regex",
"regex": "POST"
}
]
},
"$.*": {
"combine": "AND",
"matchers": [
{
"match": "type"
}
]
}
}
},
{
"generators": { },
"index": 1,
"rules": {
"$.name": {
"combine": "AND",
"matchers": [
{
"match": "regex",
"regex": "delete\\-item"
}
]
},
"$.method": {
"combine": "AND",
"matchers": [
{
"match": "regex",
"regex": "DELETE"
}
]
},
"$.*": {
"combine": "AND",
"matchers": [
{
"match": "type"
}
]
}
}
}
]
}
]
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"body": {
"$": {
"combine": "AND",
"matchers": [
{
"match": "eachKey",
"rules": [
{
"match": "regex",
"regex": "[a-z]+"
}
],
"value": "one"
}
]
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"body": {
"$": {
"combine": "AND",
"matchers": [
{
"match": "eachValue",
"rules": [
{
"match": "regex",
"regex": "[a-z]+"
}
],
"value": "one"
}
]
}
}
}
65 changes: 65 additions & 0 deletions compatibility-suite/pact-compatibility-suite/fixtures/siren.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
{
"class": [
"order"
],
"properties": {
"orderNumber": 42,
"itemCount": 3,
"status": "pending"
},
"entities": [
{
"class": [
"items",
"collection"
],
"rel": [ "http://x.io/rels/order-items" ],
"href": "http://api.x.io/orders/42/items"
},
{
"class": [
"info",
"customer"
],
"rel": [ "http://x.io/rels/customer" ],
"properties": {
"customerId": "pj123",
"name": "Peter Joseph"
},
"links": [
{
"rel": [ "self" ],
"href": "http://api.x.io/customers/pj123"
}
]
}
],
"actions": [
{
"name": "add-item",
"title": "Add Item",
"method": "POST",
"href": "http://api.x.io/orders/42/items"
},
{
"name": "delete-item",
"title": "Delete Item",
"method": "DELETE",
"href": "http://api.x.io/orders/42/items"
}
],
"links": [
{
"rel": [ "self" ],
"href": "http://api.x.io/orders/42"
},
{
"rel": [ "previous" ],
"href": "http://api.x.io/orders/41"
},
{
"rel": [ "next" ],
"href": "http://api.x.io/orders/43"
}
]
}
71 changes: 71 additions & 0 deletions compatibility-suite/pact-compatibility-suite/fixtures/siren2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
{
"class": [
"order"
],
"properties": {
"orderNumber": 42,
"itemCount": 3,
"status": "pending"
},
"entities": [
{
"class": [
"items",
"collection"
],
"rel": [ "http://x.io/rels/order-items" ],
"href": "http://api.x.io/orders/42/items"
},
{
"class": [
"info",
"customer"
],
"rel": [ "http://x.io/rels/customer" ],
"properties": {
"customerId": "pj123",
"name": "Peter Joseph"
},
"links": [
{
"rel": [ "self" ],
"href": "http://api.x.io/customers/pj123"
}
]
}
],
"actions": [
{
"name": "delete-item",
"title": "Delete Item",
"method": "DELETE",
"href": "http://api.x.io/orders/42/items"
},
{
"name": "add-item",
"title": "Add Item",
"method": "POST",
"href": "http://api.x.io/orders/42/items"
},
{
"name": "update-item",
"title": "Update Item",
"method": "PUT",
"href": "http://api.x.io/orders/42/items"
}
],
"links": [
{
"rel": [ "self" ],
"href": "http://api.x.io/orders/42"
},
{
"rel": [ "previous" ],
"href": "http://api.x.io/orders/41"
},
{
"rel": [ "next" ],
"href": "http://api.x.io/orders/43"
}
]
}
Loading

0 comments on commit 41e220d

Please sign in to comment.