Skip to content

Commit

Permalink
feat: show initial pact consumer ffi examples
Browse files Browse the repository at this point in the history
  • Loading branch information
YOU54F committed Jul 27, 2023
1 parent 7145a02 commit 7b5b3a0
Show file tree
Hide file tree
Showing 11 changed files with 785 additions and 190 deletions.
107 changes: 107 additions & 0 deletions examples/pacts/grpc-consumer-python-area-calculator-provider.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
{
"consumer": {
"name": "grpc-consumer-python"
},
"interactions": [
{
"description": "A gRPC calculateMulti request",
"interactionMarkup": {
"markup": "```protobuf\nmessage AreaResponse {\n repeated float value = 1;\n}\n```\n",
"markupType": "COMMON_MARK"
},
"pending": false,
"pluginConfiguration": {
"protobuf": {
"descriptorKey": "a85dff8f82655a9681aad113575dcfbb",
"service": "Calculator/calculateOne"
}
},
"request": {
"contents": {
"content": "EgoNAABAQBUAAIBA",
"contentType": "application/protobuf;message=ShapeMessage",
"contentTypeHint": "BINARY",
"encoded": "base64"
},
"matchingRules": {
"body": {
"$.rectangle.length": {
"combine": "AND",
"matchers": [
{
"match": "number"
}
]
},
"$.rectangle.width": {
"combine": "AND",
"matchers": [
{
"match": "number"
}
]
}
}
},
"metadata": {
"contentType": "application/protobuf;message=ShapeMessage"
}
},
"response": [
{
"contents": {
"content": "CgQAAEBB",
"contentType": "application/protobuf;message=AreaResponse",
"contentTypeHint": "BINARY",
"encoded": "base64"
},
"matchingRules": {
"body": {
"$.value[0].*": {
"combine": "AND",
"matchers": [
{
"match": "number"
}
]
}
}
},
"metadata": {
"contentType": "application/protobuf;message=AreaResponse"
}
}
],
"transport": "grpc",
"type": "Synchronous/Messages"
}
],
"metadata": {
"pact-python": {
"ffi": "0.4.5"
},
"pactRust": {
"ffi": "0.4.5",
"mockserver": "1.1.1",
"models": "1.1.2"
},
"pactSpecification": {
"version": "4.0"
},
"plugins": [
{
"configuration": {
"a85dff8f82655a9681aad113575dcfbb": {
"protoDescriptors": "CsoHChVhcmVhX2NhbGN1bGF0b3IucHJvdG8SD2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YXRvci5TaGFwZU1lc3NhZ2UaHS5hcmVhX2NhbGN1bGF0b3IuQXJlYVJlc3BvbnNlIgASTwoOY2FsY3VsYXRlTXVsdGkSHC5hcmVhX2NhbGN1bGF0b3IuQXJlYVJlcXVlc3QaHS5hcmVhX2NhbGN1bGF0b3IuQXJlYVJlc3BvbnNlIgBCHFoXaW8ucGFjdC9hcmVhX2NhbGN1bGF0b3LQAgFiBnByb3RvMw==",
"protoFile": "syntax = \"proto3\";\n\npackage area_calculator;\n\noption php_generic_services = true;\noption go_package = \"io.pact/area_calculator\";\n\nservice Calculator {\n rpc calculateOne (ShapeMessage) returns (AreaResponse) {}\n rpc calculateMulti (AreaRequest) returns (AreaResponse) {}\n}\n\nmessage ShapeMessage {\n oneof shape {\n Square square = 1;\n Rectangle rectangle = 2;\n Circle circle = 3;\n Triangle triangle = 4;\n Parallelogram parallelogram = 5;\n }\n}\n\nmessage Square {\n float edge_length = 1;\n}\n\nmessage Rectangle {\n float length = 1;\n float width = 2;\n}\n\nmessage Circle {\n float radius = 1;\n}\n\nmessage Triangle {\n float edge_a = 1;\n float edge_b = 2;\n float edge_c = 3;\n}\n\nmessage Parallelogram {\n float base_length = 1;\n float height = 2;\n}\n\nmessage AreaRequest {\n repeated ShapeMessage shapes = 1;\n}\n\nmessage AreaResponse {\n repeated float value = 1;\n}"
}
},
"name": "protobuf",
"version": "0.3.4"
}
]
},
"provider": {
"name": "area-calculator-provider"
}
}
154 changes: 154 additions & 0 deletions examples/pacts/http-consumer-1-http-provider.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
{
"consumer": {
"name": "http-consumer-1"
},
"interactions": [
{
"description": "A POST request to create book",
"providerStates": [
{
"name": "No book fixtures required"
}
],
"request": {
"body": {
"author": "Margaret Atwood",
"description": "Brilliantly conceived and executed, this powerful evocation of twenty-first century America gives full rein to Margaret Atwood's devastating irony, wit and astute perception.",
"isbn": "0099740915",
"publicationDate": "1985-07-31T00:00:00+00:00",
"title": "The Handmaid's Tale"
},
"headers": {
"Content-Type": "application/json"
},
"matchingRules": {
"body": {
"$.author": {
"combine": "AND",
"matchers": [
{
"match": "type"
}
]
},
"$.description": {
"combine": "AND",
"matchers": [
{
"match": "type"
}
]
},
"$.isbn": {
"combine": "AND",
"matchers": [
{
"match": "type"
}
]
},
"$.publicationDate": {
"combine": "AND",
"matchers": [
{
"match": "regex",
"regex": "^\\d{4}-[01]\\d-[0-3]\\dT[0-2]\\d:[0-5]\\d:[0-5]\\d([+-][0-2]\\d:[0-5]\\d|Z)$"
}
]
},
"$.title": {
"combine": "AND",
"matchers": [
{
"match": "type"
}
]
}
},
"header": {}
},
"method": "POST",
"path": "/api/books"
},
"response": {
"body": {
"@context": "/api/contexts/Book",
"@id": "/api/books/0114b2a8-3347-49d8-ad99-0e792c5a30e6",
"@type": "Book",
"author": "Melisa Kassulke",
"description": "Quaerat odit quia nisi accusantium natus voluptatem. Explicabo corporis eligendi ut ut sapiente ut qui quidem. Optio amet velit aut delectus. Sed alias asperiores perspiciatis deserunt omnis. Mollitia unde id in.",
"publicationDate": "1999-02-13T00:00:00+07:00",
"reviews": [],
"title": "Voluptas et tempora repellat corporis excepturi."
},
"headers": {
"Content-Type": "application/ld+json; charset=utf-8"
},
"matchingRules": {
"body": {
"$.author": {
"combine": "AND",
"matchers": [
{
"match": "type"
}
]
},
"$.description": {
"combine": "AND",
"matchers": [
{
"match": "type"
}
]
},
"$.publicationDate": {
"combine": "AND",
"matchers": [
{
"match": "regex",
"regex": "^\\d{4}-[01]\\d-[0-3]\\dT[0-2]\\d:[0-5]\\d:[0-5]\\d([+-][0-2]\\d:[0-5]\\d|Z)$"
}
]
},
"$.title": {
"combine": "AND",
"matchers": [
{
"match": "type"
}
]
},
"$['@id']": {
"combine": "AND",
"matchers": [
{
"match": "regex",
"regex": "^\\/api\\/books\\/[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}$"
}
]
}
},
"header": {}
},
"status": 200
}
}
],
"metadata": {
"pact-python": {
"ffi": "0.4.5"
},
"pactRust": {
"ffi": "0.4.5",
"mockserver": "1.1.1",
"models": "1.1.2"
},
"pactSpecification": {
"version": "3.0.0"
}
},
"provider": {
"name": "http-provider"
}
}
42 changes: 42 additions & 0 deletions examples/pacts/http-consumer-2-http-provider.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"consumer": {
"name": "http-consumer-2"
},
"interactions": [
{
"description": "A PUT request to generate book cover",
"providerStates": [
{
"name": "A book with id fb5a885f-f7e8-4a50-950f-c1a64a94d500 is required"
}
],
"request": {
"body": [],
"headers": {
"Content-Type": "application/json"
},
"method": "PUT",
"path": "/api/books/fb5a885f-f7e8-4a50-950f-c1a64a94d500/generate-cover"
},
"response": {
"status": 204
}
}
],
"metadata": {
"pact-python": {
"ffi": "0.4.5"
},
"pactRust": {
"ffi": "0.4.5",
"mockserver": "1.1.1",
"models": "1.1.2"
},
"pactSpecification": {
"version": "3.0.0"
}
},
"provider": {
"name": "http-provider"
}
}
46 changes: 46 additions & 0 deletions examples/pacts/message-consumer-2-message-provider.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"consumer": {
"name": "message-consumer-2"
},
"messages": [
{
"contents": {
"uuid": "fb5a885f-f7e8-4a50-950f-c1a64a94d500"
},
"description": "Book (id fb5a885f-f7e8-4a50-950f-c1a64a94d500) created message",
"matchingRules": {
"body": {
"$.uuid": {
"combine": "AND",
"matchers": [
{
"match": "regex",
"regex": "^[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}$"
}
]
}
}
},
"metadata": {
"contentType": "application/json"
},
"providerStates": [
{
"name": "A book with id fb5a885f-f7e8-4a50-950f-c1a64a94d500 is required"
}
]
}
],
"metadata": {
"pactRust": {
"ffi": "0.4.5",
"models": "1.1.2"
},
"pactSpecification": {
"version": "3.0.0"
}
},
"provider": {
"name": "message-provider"
}
}
Loading

0 comments on commit 7b5b3a0

Please sign in to comment.