From b15225c9dff2864ee774a0ab1dcf19d9353ec10b Mon Sep 17 00:00:00 2001 From: Ruben Beltran del Rio Date: Sun, 2 May 2021 19:53:10 +0200 Subject: Add posts store pact test --- pacts/forumclient-forumserver.json | 427 ++++++++++++++++++++++++++++++++++ pacts/forumsstore-forumapiserver.json | 284 ---------------------- 2 files changed, 427 insertions(+), 284 deletions(-) create mode 100644 pacts/forumclient-forumserver.json delete mode 100644 pacts/forumsstore-forumapiserver.json (limited to 'pacts') diff --git a/pacts/forumclient-forumserver.json b/pacts/forumclient-forumserver.json new file mode 100644 index 0000000..b1c7fcb --- /dev/null +++ b/pacts/forumclient-forumserver.json @@ -0,0 +1,427 @@ +{ + "consumer": { + "name": "ForumClient" + }, + "provider": { + "name": "ForumServer" + }, + "interactions": [ + { + "description": "a request to get a single post", + "providerState": "there's data", + "request": { + "method": "POST", + "path": "/graphql", + "headers": { + "content-type": "application/json" + }, + "body": { + "operationName": "GetPost", + "query": "query GetPost($id: ID!) {\n post(id: $id) {\n id\n text\n created_at\n author {\n id\n handle\n __typename\n }\n topic {\n id\n title\n __typename\n }\n __typename\n }\n }", + "variables": { + "id": "freezer" + } + }, + "matchingRules": { + "$.body.query": { + "match": "regex", + "regex": "query\\s*GetPost\\(\\$id:\\s*ID!\\)\\s*\\{\\s*post\\(id:\\s*\\$id\\)\\s*\\{\\s*id\\s*text\\s*created_at\\s*author\\s*\\{\\s*id\\s*handle\\s*__typename\\s*\\}\\s*topic\\s*\\{\\s*id\\s*title\\s*__typename\\s*\\}\\s*__typename\\s*\\}\\s*\\}" + } + } + }, + "response": { + "status": 200, + "headers": { + "Content-Type": "application/json; charset=utf-8" + }, + "body": { + "data": { + "post": { + "id": "8f75eba5-6989-4dd3-b466-e464546ce374", + "text": "This is a very pacty post", + "created_at": 1619976194937, + "author": { + "id": "a805b3de-cac4-451c-a1e6-f078869c9db9", + "handle": "pacts_person" + }, + "topic": { + "id": "5c283ce1-0470-4b98-86f5-1fec9a22c9ac", + "title": "The parent pacts topic" + } + } + } + }, + "matchingRules": { + "$.body.data.post": { + "match": "type" + }, + "$.body.data.post.id": { + "match": "type" + }, + "$.body.data.post.text": { + "match": "type" + }, + "$.body.data.post.created_at": { + "match": "type" + }, + "$.body.data.post.author": { + "match": "type" + }, + "$.body.data.post.author.id": { + "match": "type" + }, + "$.body.data.post.author.handle": { + "match": "type" + }, + "$.body.data.post.topic": { + "match": "type" + }, + "$.body.data.post.topic.id": { + "match": "type" + }, + "$.body.data.post.topic.title": { + "match": "type" + } + } + } + }, + { + "description": "a request to get a single post", + "providerState": "there's no data", + "request": { + "method": "POST", + "path": "/graphql", + "headers": { + "content-type": "application/json" + }, + "body": { + "operationName": "GetPost", + "query": "query GetPost($id: ID!) {\n post(id: $id) {\n id\n text\n created_at\n author {\n id\n handle\n __typename\n }\n topic {\n id\n title\n __typename\n }\n __typename\n }\n }", + "variables": { + "id": "freezer" + } + }, + "matchingRules": { + "$.body.query": { + "match": "regex", + "regex": "query\\s*GetPost\\(\\$id:\\s*ID!\\)\\s*\\{\\s*post\\(id:\\s*\\$id\\)\\s*\\{\\s*id\\s*text\\s*created_at\\s*author\\s*\\{\\s*id\\s*handle\\s*__typename\\s*\\}\\s*topic\\s*\\{\\s*id\\s*title\\s*__typename\\s*\\}\\s*__typename\\s*\\}\\s*\\}" + } + } + }, + "response": { + "status": 200, + "headers": { + "Content-Type": "application/json; charset=utf-8" + }, + "body": { + "data": { + "post": null + } + } + } + }, + { + "description": "a request to get a single post", + "providerState": "there's an error", + "request": { + "method": "POST", + "path": "/graphql", + "headers": { + "content-type": "application/json" + }, + "body": { + "operationName": "GetPost", + "query": "query GetPost($id: ID!) {\n post(id: $id) {\n id\n text\n created_at\n author {\n id\n handle\n __typename\n }\n topic {\n id\n title\n __typename\n }\n __typename\n }\n }", + "variables": { + "id": "freezer" + } + }, + "matchingRules": { + "$.body.query": { + "match": "regex", + "regex": "query\\s*GetPost\\(\\$id:\\s*ID!\\)\\s*\\{\\s*post\\(id:\\s*\\$id\\)\\s*\\{\\s*id\\s*text\\s*created_at\\s*author\\s*\\{\\s*id\\s*handle\\s*__typename\\s*\\}\\s*topic\\s*\\{\\s*id\\s*title\\s*__typename\\s*\\}\\s*__typename\\s*\\}\\s*\\}" + } + } + }, + "response": { + "status": 500, + "headers": { + } + } + }, + { + "description": "a request to list the forums", + "providerState": "there's data", + "request": { + "method": "POST", + "path": "/graphql", + "headers": { + "content-type": "application/json" + }, + "body": { + "operationName": "GetForums", + "query": "query GetForums {\n forums {\n id\n glyph\n label\n position\n __typename\n }\n }", + "variables": { + } + }, + "matchingRules": { + "$.body.query": { + "match": "regex", + "regex": "query\\s*GetForums\\s*\\{\\s*forums\\s*\\{\\s*id\\s*glyph\\s*label\\s*position\\s*__typename\\s*\\}\\s*\\}" + } + } + }, + "response": { + "status": 200, + "headers": { + "Content-Type": "application/json; charset=utf-8" + }, + "body": { + "data": { + "forums": [ + { + "id": "butter", + "glyph": "⌘", + "label": "test_forums.butter", + "position": 1 + } + ] + } + }, + "matchingRules": { + "$.body.data.forums": { + "min": 1 + }, + "$.body.data.forums[*].*": { + "match": "type" + }, + "$.body.data.forums[*].id": { + "match": "type" + }, + "$.body.data.forums[*].glyph": { + "match": "type" + }, + "$.body.data.forums[*].label": { + "match": "type" + }, + "$.body.data.forums[*].position": { + "match": "type" + } + } + } + }, + { + "description": "a request to get a single forum", + "providerState": "there's data", + "request": { + "method": "POST", + "path": "/graphql", + "headers": { + "content-type": "application/json" + }, + "body": { + "operationName": "GetForum", + "query": "query GetForum($id: ID!) {\n forum(id: $id) {\n id\n glyph\n label\n position\n topics {\n id\n title\n updated_at\n ttl\n __typename\n }\n __typename\n }\n }", + "variables": { + "id": "freezer" + } + }, + "matchingRules": { + "$.body.query": { + "match": "regex", + "regex": "query\\s*GetForum\\(\\$id:\\s*ID!\\)\\s*\\{\\s*forum\\(id:\\s*\\$id\\)\\s*\\{\\s*id\\s*glyph\\s*label\\s*position\\s*topics\\s*\\{\\s*id\\s*title\\s*updated_at\\s*ttl\\s*__typename\\s*\\}\\s*__typename\\s*\\}\\s*\\}" + } + } + }, + "response": { + "status": 200, + "headers": { + "Content-Type": "application/json; charset=utf-8" + }, + "body": { + "data": { + "forum": { + "id": "freezer", + "glyph": "✭", + "label": "test_forums.freezer", + "position": 3, + "topics": [ + { + "id": "629de02c-151a-4db7-bb86-43b2add8a15a", + "title": "Very pacty topic", + "updated_at": 1619954611616, + "ttl": 3601 + } + ] + } + } + }, + "matchingRules": { + "$.body.data.forum": { + "match": "type" + }, + "$.body.data.forum.glyph": { + "match": "type" + }, + "$.body.data.forum.label": { + "match": "type" + }, + "$.body.data.forum.position": { + "match": "type" + }, + "$.body.data.forum.topics": { + "min": 1 + }, + "$.body.data.forum.topics[*].*": { + "match": "type" + }, + "$.body.data.forum.topics[*].id": { + "match": "type" + }, + "$.body.data.forum.topics[*].title": { + "match": "type" + }, + "$.body.data.forum.topics[*].updated_at": { + "match": "type" + }, + "$.body.data.forum.topics[*].ttl": { + "match": "type" + } + } + } + }, + { + "description": "a request to list the forums", + "providerState": "there's no data", + "request": { + "method": "POST", + "path": "/graphql", + "headers": { + "content-type": "application/json" + }, + "body": { + "operationName": "GetForums", + "query": "query GetForums {\n forums {\n id\n glyph\n label\n position\n __typename\n }\n }", + "variables": { + } + }, + "matchingRules": { + "$.body.query": { + "match": "regex", + "regex": "query\\s*GetForums\\s*\\{\\s*forums\\s*\\{\\s*id\\s*glyph\\s*label\\s*position\\s*__typename\\s*\\}\\s*\\}" + } + } + }, + "response": { + "status": 200, + "headers": { + "Content-Type": "application/json; charset=utf-8" + }, + "body": { + "data": { + "forums": [ + + ] + } + } + } + }, + { + "description": "a request to get a single forum", + "providerState": "there's no data", + "request": { + "method": "POST", + "path": "/graphql", + "headers": { + "content-type": "application/json" + }, + "body": { + "operationName": "GetForum", + "query": "query GetForum($id: ID!) {\n forum(id: $id) {\n id\n glyph\n label\n position\n topics {\n id\n title\n updated_at\n ttl\n __typename\n }\n __typename\n }\n }", + "variables": { + "id": "freezer" + } + }, + "matchingRules": { + "$.body.query": { + "match": "regex", + "regex": "query\\s*GetForum\\(\\$id:\\s*ID!\\)\\s*\\{\\s*forum\\(id:\\s*\\$id\\)\\s*\\{\\s*id\\s*glyph\\s*label\\s*position\\s*topics\\s*\\{\\s*id\\s*title\\s*updated_at\\s*ttl\\s*__typename\\s*\\}\\s*__typename\\s*\\}\\s*\\}" + } + } + }, + "response": { + "status": 200, + "headers": { + "Content-Type": "application/json; charset=utf-8" + }, + "body": { + "data": { + "forum": null + } + } + } + }, + { + "description": "a request to list the forums", + "providerState": "there's an error", + "request": { + "method": "POST", + "path": "/graphql", + "headers": { + "content-type": "application/json" + }, + "body": { + "operationName": "GetForums", + "query": "query GetForums {\n forums {\n id\n glyph\n label\n position\n __typename\n }\n }", + "variables": { + } + }, + "matchingRules": { + "$.body.query": { + "match": "regex", + "regex": "query\\s*GetForums\\s*\\{\\s*forums\\s*\\{\\s*id\\s*glyph\\s*label\\s*position\\s*__typename\\s*\\}\\s*\\}" + } + } + }, + "response": { + "status": 500, + "headers": { + } + } + }, + { + "description": "a request to get a single forum", + "providerState": "there's an error", + "request": { + "method": "POST", + "path": "/graphql", + "headers": { + "content-type": "application/json" + }, + "body": { + "operationName": "GetForum", + "query": "query GetForum($id: ID!) {\n forum(id: $id) {\n id\n glyph\n label\n position\n topics {\n id\n title\n updated_at\n ttl\n __typename\n }\n __typename\n }\n }", + "variables": { + "id": "freezer" + } + }, + "matchingRules": { + "$.body.query": { + "match": "regex", + "regex": "query\\s*GetForum\\(\\$id:\\s*ID!\\)\\s*\\{\\s*forum\\(id:\\s*\\$id\\)\\s*\\{\\s*id\\s*glyph\\s*label\\s*position\\s*topics\\s*\\{\\s*id\\s*title\\s*updated_at\\s*ttl\\s*__typename\\s*\\}\\s*__typename\\s*\\}\\s*\\}" + } + } + }, + "response": { + "status": 500, + "headers": { + } + } + } + ], + "metadata": { + "pactSpecification": { + "version": "2.0.0" + } + } +} \ No newline at end of file diff --git a/pacts/forumsstore-forumapiserver.json b/pacts/forumsstore-forumapiserver.json deleted file mode 100644 index c0e784b..0000000 --- a/pacts/forumsstore-forumapiserver.json +++ /dev/null @@ -1,284 +0,0 @@ -{ - "consumer": { - "name": "ForumsStore" - }, - "provider": { - "name": "ForumAPIServer" - }, - "interactions": [ - { - "description": "a request to list the forums", - "providerState": "there's forums", - "request": { - "method": "POST", - "path": "/graphql", - "headers": { - "content-type": "application/json" - }, - "body": { - "operationName": "GetForums", - "query": "query GetForums {\n forums {\n id\n glyph\n label\n position\n __typename\n }\n }", - "variables": { - } - }, - "matchingRules": { - "$.body.query": { - "match": "regex", - "regex": "query\\s*GetForums\\s*\\{\\s*forums\\s*\\{\\s*id\\s*glyph\\s*label\\s*position\\s*__typename\\s*\\}\\s*\\}" - } - } - }, - "response": { - "status": 200, - "headers": { - "Content-Type": "application/json; charset=utf-8" - }, - "body": { - "data": { - "forums": [ - { - "id": "butter", - "glyph": "⌘", - "label": "test_forums.butter", - "position": 1 - } - ] - } - }, - "matchingRules": { - "$.body.data.forums": { - "min": 1 - }, - "$.body.data.forums[*].*": { - "match": "type" - }, - "$.body.data.forums[*].id": { - "match": "type" - }, - "$.body.data.forums[*].glyph": { - "match": "type" - }, - "$.body.data.forums[*].label": { - "match": "type" - }, - "$.body.data.forums[*].position": { - "match": "type" - } - } - } - }, - { - "description": "a request to get a single forum", - "providerState": "there's forums", - "request": { - "method": "POST", - "path": "/graphql", - "headers": { - "content-type": "application/json" - }, - "body": { - "operationName": "GetForum", - "query": "query GetForum($id: ID!) {\n forum(id: $id) {\n id\n glyph\n label\n position\n topics {\n id\n title\n updated_at\n ttl\n __typename\n }\n __typename\n }\n }", - "variables": { - "id": "freezer" - } - }, - "matchingRules": { - "$.body.query": { - "match": "regex", - "regex": "query\\s*GetForum\\(\\$id:\\s*ID!\\)\\s*\\{\\s*forum\\(id:\\s*\\$id\\)\\s*\\{\\s*id\\s*glyph\\s*label\\s*position\\s*topics\\s*\\{\\s*id\\s*title\\s*updated_at\\s*ttl\\s*__typename\\s*\\}\\s*__typename\\s*\\}\\s*\\}" - } - } - }, - "response": { - "status": 200, - "headers": { - "Content-Type": "application/json; charset=utf-8" - }, - "body": { - "data": { - "forum": { - "id": "freezer", - "glyph": "✭", - "label": "test_forums.freezer", - "position": 3, - "topics": [ - { - "id": "629de02c-151a-4db7-bb86-43b2add8a15a", - "title": "Very pacty topic", - "updated_at": 1619954611616, - "ttl": 3601 - } - ] - } - } - }, - "matchingRules": { - "$.body.data.forum": { - "match": "type" - }, - "$.body.data.forum.glyph": { - "match": "type" - }, - "$.body.data.forum.label": { - "match": "type" - }, - "$.body.data.forum.position": { - "match": "type" - }, - "$.body.data.forum.topics": { - "min": 1 - }, - "$.body.data.forum.topics[*].*": { - "match": "type" - }, - "$.body.data.forum.topics[*].id": { - "match": "type" - }, - "$.body.data.forum.topics[*].title": { - "match": "type" - }, - "$.body.data.forum.topics[*].updated_at": { - "match": "type" - }, - "$.body.data.forum.topics[*].ttl": { - "match": "type" - } - } - } - }, - { - "description": "a request to list the forums", - "providerState": "there's no forums", - "request": { - "method": "POST", - "path": "/graphql", - "headers": { - "content-type": "application/json" - }, - "body": { - "operationName": "GetForums", - "query": "query GetForums {\n forums {\n id\n glyph\n label\n position\n __typename\n }\n }", - "variables": { - } - }, - "matchingRules": { - "$.body.query": { - "match": "regex", - "regex": "query\\s*GetForums\\s*\\{\\s*forums\\s*\\{\\s*id\\s*glyph\\s*label\\s*position\\s*__typename\\s*\\}\\s*\\}" - } - } - }, - "response": { - "status": 200, - "headers": { - "Content-Type": "application/json; charset=utf-8" - }, - "body": { - "data": { - "forums": [ - - ] - } - } - } - }, - { - "description": "a request to get a single forum", - "providerState": "there's no forums", - "request": { - "method": "POST", - "path": "/graphql", - "headers": { - "content-type": "application/json" - }, - "body": { - "operationName": "GetForum", - "query": "query GetForum($id: ID!) {\n forum(id: $id) {\n id\n glyph\n label\n position\n topics {\n id\n title\n updated_at\n ttl\n __typename\n }\n __typename\n }\n }", - "variables": { - "id": "freezer" - } - }, - "matchingRules": { - "$.body.query": { - "match": "regex", - "regex": "query\\s*GetForum\\(\\$id:\\s*ID!\\)\\s*\\{\\s*forum\\(id:\\s*\\$id\\)\\s*\\{\\s*id\\s*glyph\\s*label\\s*position\\s*topics\\s*\\{\\s*id\\s*title\\s*updated_at\\s*ttl\\s*__typename\\s*\\}\\s*__typename\\s*\\}\\s*\\}" - } - } - }, - "response": { - "status": 200, - "headers": { - "Content-Type": "application/json; charset=utf-8" - }, - "body": { - "data": { - "forum": null - } - } - } - }, - { - "description": "a request to list the forums", - "providerState": "there's an error", - "request": { - "method": "POST", - "path": "/graphql", - "headers": { - "content-type": "application/json" - }, - "body": { - "operationName": "GetForums", - "query": "query GetForums {\n forums {\n id\n glyph\n label\n position\n __typename\n }\n }", - "variables": { - } - }, - "matchingRules": { - "$.body.query": { - "match": "regex", - "regex": "query\\s*GetForums\\s*\\{\\s*forums\\s*\\{\\s*id\\s*glyph\\s*label\\s*position\\s*__typename\\s*\\}\\s*\\}" - } - } - }, - "response": { - "status": 500, - "headers": { - } - } - }, - { - "description": "a request to get a single forum", - "providerState": "there's an error", - "request": { - "method": "POST", - "path": "/graphql", - "headers": { - "content-type": "application/json" - }, - "body": { - "operationName": "GetForum", - "query": "query GetForum($id: ID!) {\n forum(id: $id) {\n id\n glyph\n label\n position\n topics {\n id\n title\n updated_at\n ttl\n __typename\n }\n __typename\n }\n }", - "variables": { - "id": "freezer" - } - }, - "matchingRules": { - "$.body.query": { - "match": "regex", - "regex": "query\\s*GetForum\\(\\$id:\\s*ID!\\)\\s*\\{\\s*forum\\(id:\\s*\\$id\\)\\s*\\{\\s*id\\s*glyph\\s*label\\s*position\\s*topics\\s*\\{\\s*id\\s*title\\s*updated_at\\s*ttl\\s*__typename\\s*\\}\\s*__typename\\s*\\}\\s*\\}" - } - } - }, - "response": { - "status": 500, - "headers": { - } - } - } - ], - "metadata": { - "pactSpecification": { - "version": "2.0.0" - } - } -} \ No newline at end of file -- cgit