diff options
| author | Ruben Beltran del Rio <ruben@unlimited.pizza> | 2021-05-03 20:59:55 +0200 |
|---|---|---|
| committer | Ruben Beltran del Rio <ruben@unlimited.pizza> | 2021-05-03 20:59:55 +0200 |
| commit | 26dfa00e2f4eddbdc71ae4d92ee5676f11413ada (patch) | |
| tree | 9df324ee7c3b9350e521018d35b0b18f5eef4fc9 /pacts | |
| parent | 3435a35ccb828fe81720d057e38eaa4223e917a7 (diff) | |
Add tests for actions + pacts for graphql errrors
Diffstat (limited to 'pacts')
| -rw-r--r-- | pacts/forumclient-forumserver.json | 657 |
1 files changed, 448 insertions, 209 deletions
diff --git a/pacts/forumclient-forumserver.json b/pacts/forumclient-forumserver.json index 337ff86..9ec37f8 100644 --- a/pacts/forumclient-forumserver.json +++ b/pacts/forumclient-forumserver.json @@ -7,7 +7,7 @@ }, "interactions": [ { - "description": "a request to get a single post", + "description": "a request to list the forums", "providerState": "there's data", "request": { "method": "POST", @@ -16,16 +16,15 @@ "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 }", + "operationName": "GetForums", + "query": "query GetForums {\n forums {\n id\n glyph\n label\n position\n __typename\n }\n }", "variables": { - "id": "8f75eba5-6989-4dd3-b466-e464546ce374" } }, "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*\\}" + "regex": "query\\s*GetForums\\s*\\{\\s*forums\\s*\\{\\s*id\\s*glyph\\s*label\\s*position\\s*__typename\\s*\\}\\s*\\}" } } }, @@ -36,57 +35,120 @@ }, "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" + "forums": [ + { + "id": "butter", + "glyph": "⌘", + "label": "test_forums.butter", + "position": 1 } - } + ] } }, "matchingRules": { - "$.body.data.post": { + "$.body.data.forums": { + "min": 1 + }, + "$.body.data.forums[*].*": { "match": "type" }, - "$.body.data.post.id": { + "$.body.data.forums[*].id": { "match": "type" }, - "$.body.data.post.text": { + "$.body.data.forums[*].glyph": { "match": "type" }, - "$.body.data.post.created_at": { + "$.body.data.forums[*].label": { "match": "type" }, - "$.body.data.post.author": { + "$.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.post.author.id": { + "$.body.data.forum.glyph": { "match": "type" }, - "$.body.data.post.author.handle": { + "$.body.data.forum.label": { "match": "type" }, - "$.body.data.post.topic": { + "$.body.data.forum.position": { "match": "type" }, - "$.body.data.post.topic.id": { + "$.body.data.forum.topics": { + "min": 1 + }, + "$.body.data.forum.topics[*].*": { "match": "type" }, - "$.body.data.post.topic.title": { + "$.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 get a single post", + "description": "a request to list the forums", "providerState": "there's no data", "request": { "method": "POST", @@ -95,16 +157,15 @@ "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 }", + "operationName": "GetForums", + "query": "query GetForums {\n forums {\n id\n glyph\n label\n position\n __typename\n }\n }", "variables": { - "id": "8f75eba5-6989-4dd3-b466-e464546ce374" } }, "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*\\}" + "regex": "query\\s*GetForums\\s*\\{\\s*forums\\s*\\{\\s*id\\s*glyph\\s*label\\s*position\\s*__typename\\s*\\}\\s*\\}" } } }, @@ -115,14 +176,16 @@ }, "body": { "data": { - "post": null + "forums": [ + + ] } } } }, { - "description": "a request to get a single post", - "providerState": "there's an error", + "description": "a request to get a single forum", + "providerState": "there's no data", "request": { "method": "POST", "path": "/graphql", @@ -130,16 +193,79 @@ "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 }", + "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": "8f75eba5-6989-4dd3-b466-e464546ce374" + "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*\\}" + "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 a server 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 a server 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*\\}" } } }, @@ -151,7 +277,7 @@ }, { "description": "a request to list the forums", - "providerState": "there's data", + "providerState": "there's an error in the response", "request": { "method": "POST", "path": "/graphql", @@ -177,34 +303,20 @@ "Content-Type": "application/json; charset=utf-8" }, "body": { - "data": { - "forums": [ - { - "id": "butter", - "glyph": "⌘", - "label": "test_forums.butter", - "position": 1 - } - ] - } + "errors": [ + { + "message": "An error occurred when fetching forums" + } + ] }, "matchingRules": { - "$.body.data.forums": { + "$.body.errors": { "min": 1 }, - "$.body.data.forums[*].*": { + "$.body.errors[*].*": { "match": "type" }, - "$.body.data.forums[*].id": { - "match": "type" - }, - "$.body.data.forums[*].glyph": { - "match": "type" - }, - "$.body.data.forums[*].label": { - "match": "type" - }, - "$.body.data.forums[*].position": { + "$.body.errors[*].message": { "match": "type" } } @@ -212,7 +324,7 @@ }, { "description": "a request to get a single forum", - "providerState": "there's data", + "providerState": "there's an error in the response", "request": { "method": "POST", "path": "/graphql", @@ -239,60 +351,28 @@ "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 - } - ] + "errors": [ + { + "message": "An error occurred when fetching the forum" } - } + ] }, "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": { + "$.body.errors": { "min": 1 }, - "$.body.data.forum.topics[*].*": { + "$.body.errors[*].*": { "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": { + "$.body.errors[*].message": { "match": "type" } } } }, { - "description": "a request to list the forums", - "providerState": "there's no data", + "description": "a request to get a single topic", + "providerState": "there's data", "request": { "method": "POST", "path": "/graphql", @@ -300,15 +380,16 @@ "content-type": "application/json" }, "body": { - "operationName": "GetForums", - "query": "query GetForums {\n forums {\n id\n glyph\n label\n position\n __typename\n }\n }", + "operationName": "GetTopic", + "query": "query GetTopic($id: ID!) {\n topic(id: $id) {\n id\n title\n updated_at\n ttl\n forum {\n id\n glyph\n label\n __typename\n }\n tags {\n id\n weight\n __typename\n }\n posts {\n id\n text\n created_at\n author {\n id\n handle\n __typename\n }\n __typename\n }\n __typename\n }\n }", "variables": { + "id": "0b58959d-d448-4a4e-84b6-35e5ac0028d1" } }, "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*\\}" + "regex": "query\\s*GetTopic\\(\\$id:\\s*ID!\\)\\s*\\{\\s*topic\\(id:\\s*\\$id\\)\\s*\\{\\s*id\\s*title\\s*updated_at\\s*ttl\\s*forum\\s*\\{\\s*id\\s*glyph\\s*label\\s*__typename\\s*\\}\\s*tags\\s*\\{\\s*id\\s*weight\\s*__typename\\s*\\}\\s*posts\\s*\\{\\s*id\\s*text\\s*created_at\\s*author\\s*\\{\\s*id\\s*handle\\s*__typename\\s*\\}\\s*__typename\\s*\\}\\s*__typename\\s*\\}\\s*\\}" } } }, @@ -319,15 +400,99 @@ }, "body": { "data": { - "forums": [ - - ] + "topic": { + "id": "0b58959d-d448-4a4e-84b6-35e5ac0028d1", + "title": "The pacty topic of the day", + "updated_at": 1619979888906, + "ttl": 3399, + "forum": { + "id": "cucumber", + "glyph": "✽", + "label": "test_forums.cucumber" + }, + "tags": [ + { + "id": "skunk", + "weight": 44 + } + ], + "posts": [ + { + "id": "ed93530e-6f9c-4701-91ef-14f9e0ed3e26", + "text": "The content of this post is very relevant", + "created_at": 1619979889798, + "author": { + "id": "07fb2ba0-0945-464a-b215-873296710c8c", + "handle": "cucumber_fan92" + } + } + ] + } + } + }, + "matchingRules": { + "$.body.data.topic.id": { + "match": "type" + }, + "$.body.data.topic.title": { + "match": "type" + }, + "$.body.data.topic.updated_at": { + "match": "type" + }, + "$.body.data.topic.ttl": { + "match": "type" + }, + "$.body.data.topic.forum.id": { + "match": "type" + }, + "$.body.data.topic.forum.glyph": { + "match": "type" + }, + "$.body.data.topic.forum.label": { + "match": "type" + }, + "$.body.data.topic.tags": { + "min": 1 + }, + "$.body.data.topic.tags[*].*": { + "match": "type" + }, + "$.body.data.topic.tags[*].id": { + "match": "type" + }, + "$.body.data.topic.tags[*].weight": { + "match": "type" + }, + "$.body.data.topic.posts": { + "min": 1 + }, + "$.body.data.topic.posts[*].*": { + "match": "type" + }, + "$.body.data.topic.posts[*].id": { + "match": "type" + }, + "$.body.data.topic.posts[*].text": { + "match": "type" + }, + "$.body.data.topic.posts[*].created_at": { + "match": "type" + }, + "$.body.data.topic.posts[*].author": { + "match": "type" + }, + "$.body.data.topic.posts[*].author.id": { + "match": "type" + }, + "$.body.data.topic.posts[*].author.handle": { + "match": "type" } } } }, { - "description": "a request to get a single forum", + "description": "a request to get a single topic", "providerState": "there's no data", "request": { "method": "POST", @@ -336,16 +501,16 @@ "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 }", + "operationName": "GetTopic", + "query": "query GetTopic($id: ID!) {\n topic(id: $id) {\n id\n title\n updated_at\n ttl\n forum {\n id\n glyph\n label\n __typename\n }\n tags {\n id\n weight\n __typename\n }\n posts {\n id\n text\n created_at\n author {\n id\n handle\n __typename\n }\n __typename\n }\n __typename\n }\n }", "variables": { - "id": "freezer" + "id": "0b58959d-d448-4a4e-84b6-35e5ac0028d1" } }, "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*\\}" + "regex": "query\\s*GetTopic\\(\\$id:\\s*ID!\\)\\s*\\{\\s*topic\\(id:\\s*\\$id\\)\\s*\\{\\s*id\\s*title\\s*updated_at\\s*ttl\\s*forum\\s*\\{\\s*id\\s*glyph\\s*label\\s*__typename\\s*\\}\\s*tags\\s*\\{\\s*id\\s*weight\\s*__typename\\s*\\}\\s*posts\\s*\\{\\s*id\\s*text\\s*created_at\\s*author\\s*\\{\\s*id\\s*handle\\s*__typename\\s*\\}\\s*__typename\\s*\\}\\s*__typename\\s*\\}\\s*\\}" } } }, @@ -356,14 +521,14 @@ }, "body": { "data": { - "forum": null + "topic": null } } } }, { - "description": "a request to list the forums", - "providerState": "there's an error", + "description": "a request to get a single topic", + "providerState": "there's a server error", "request": { "method": "POST", "path": "/graphql", @@ -371,15 +536,16 @@ "content-type": "application/json" }, "body": { - "operationName": "GetForums", - "query": "query GetForums {\n forums {\n id\n glyph\n label\n position\n __typename\n }\n }", + "operationName": "GetTopic", + "query": "query GetTopic($id: ID!) {\n topic(id: $id) {\n id\n title\n updated_at\n ttl\n forum {\n id\n glyph\n label\n __typename\n }\n tags {\n id\n weight\n __typename\n }\n posts {\n id\n text\n created_at\n author {\n id\n handle\n __typename\n }\n __typename\n }\n __typename\n }\n }", "variables": { + "id": "0b58959d-d448-4a4e-84b6-35e5ac0028d1" } }, "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*\\}" + "regex": "query\\s*GetTopic\\(\\$id:\\s*ID!\\)\\s*\\{\\s*topic\\(id:\\s*\\$id\\)\\s*\\{\\s*id\\s*title\\s*updated_at\\s*ttl\\s*forum\\s*\\{\\s*id\\s*glyph\\s*label\\s*__typename\\s*\\}\\s*tags\\s*\\{\\s*id\\s*weight\\s*__typename\\s*\\}\\s*posts\\s*\\{\\s*id\\s*text\\s*created_at\\s*author\\s*\\{\\s*id\\s*handle\\s*__typename\\s*\\}\\s*__typename\\s*\\}\\s*__typename\\s*\\}\\s*\\}" } } }, @@ -390,8 +556,8 @@ } }, { - "description": "a request to get a single forum", - "providerState": "there's an error", + "description": "a request to get a single topic", + "providerState": "there's an error in the response", "request": { "method": "POST", "path": "/graphql", @@ -399,22 +565,41 @@ "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 }", + "operationName": "GetTopic", + "query": "query GetTopic($id: ID!) {\n topic(id: $id) {\n id\n title\n updated_at\n ttl\n forum {\n id\n glyph\n label\n __typename\n }\n tags {\n id\n weight\n __typename\n }\n posts {\n id\n text\n created_at\n author {\n id\n handle\n __typename\n }\n __typename\n }\n __typename\n }\n }", "variables": { - "id": "freezer" + "id": "0b58959d-d448-4a4e-84b6-35e5ac0028d1" } }, "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*\\}" + "regex": "query\\s*GetTopic\\(\\$id:\\s*ID!\\)\\s*\\{\\s*topic\\(id:\\s*\\$id\\)\\s*\\{\\s*id\\s*title\\s*updated_at\\s*ttl\\s*forum\\s*\\{\\s*id\\s*glyph\\s*label\\s*__typename\\s*\\}\\s*tags\\s*\\{\\s*id\\s*weight\\s*__typename\\s*\\}\\s*posts\\s*\\{\\s*id\\s*text\\s*created_at\\s*author\\s*\\{\\s*id\\s*handle\\s*__typename\\s*\\}\\s*__typename\\s*\\}\\s*__typename\\s*\\}\\s*\\}" } } }, "response": { - "status": 500, + "status": 200, "headers": { + "Content-Type": "application/json; charset=utf-8" + }, + "body": { + "errors": [ + { + "message": "An error occurred when fetching the topic" + } + ] + }, + "matchingRules": { + "$.body.errors": { + "min": 1 + }, + "$.body.errors[*].*": { + "match": "type" + }, + "$.body.errors[*].message": { + "match": "type" + } } } }, @@ -523,7 +708,7 @@ }, { "description": "a request to get a single tag", - "providerState": "there's an error", + "providerState": "there's a server error", "request": { "method": "POST", "path": "/graphql", @@ -551,8 +736,8 @@ } }, { - "description": "a request to get a single topic", - "providerState": "there's data", + "description": "a request to get a single tag", + "providerState": "there's an error in the response", "request": { "method": "POST", "path": "/graphql", @@ -560,16 +745,16 @@ "content-type": "application/json" }, "body": { - "operationName": "GetTopic", - "query": "query GetTopic($id: ID!) {\n topic(id: $id) {\n id\n title\n updated_at\n ttl\n forum {\n id\n glyph\n label\n __typename\n }\n tags {\n id\n weight\n __typename\n }\n posts {\n id\n text\n created_at\n author {\n id\n handle\n __typename\n }\n __typename\n }\n __typename\n }\n }", + "operationName": "GetTag", + "query": "query GetTag($id: ID!) {\n tag(id: $id) {\n id\n topics {\n id\n title\n updated_at\n ttl\n __typename\n }\n __typename\n }\n }", "variables": { - "id": "0b58959d-d448-4a4e-84b6-35e5ac0028d1" + "id": "pineapple" } }, "matchingRules": { "$.body.query": { "match": "regex", - "regex": "query\\s*GetTopic\\(\\$id:\\s*ID!\\)\\s*\\{\\s*topic\\(id:\\s*\\$id\\)\\s*\\{\\s*id\\s*title\\s*updated_at\\s*ttl\\s*forum\\s*\\{\\s*id\\s*glyph\\s*label\\s*__typename\\s*\\}\\s*tags\\s*\\{\\s*id\\s*weight\\s*__typename\\s*\\}\\s*posts\\s*\\{\\s*id\\s*text\\s*created_at\\s*author\\s*\\{\\s*id\\s*handle\\s*__typename\\s*\\}\\s*__typename\\s*\\}\\s*__typename\\s*\\}\\s*\\}" + "regex": "query\\s*GetTag\\(\\$id:\\s*ID!\\)\\s*\\{\\s*tag\\(id:\\s*\\$id\\)\\s*\\{\\s*id\\s*topics\\s*\\{\\s*id\\s*title\\s*updated_at\\s*ttl\\s*__typename\\s*\\}\\s*__typename\\s*\\}\\s*\\}" } } }, @@ -579,100 +764,106 @@ "Content-Type": "application/json; charset=utf-8" }, "body": { - "data": { - "topic": { - "id": "0b58959d-d448-4a4e-84b6-35e5ac0028d1", - "title": "The pacty topic of the day", - "updated_at": 1619979888906, - "ttl": 3399, - "forum": { - "id": "cucumber", - "glyph": "✽", - "label": "test_forums.cucumber" - }, - "tags": [ - { - "id": "skunk", - "weight": 44 - } - ], - "posts": [ - { - "id": "ed93530e-6f9c-4701-91ef-14f9e0ed3e26", - "text": "The content of this post is very relevant", - "created_at": 1619979889798, - "author": { - "id": "07fb2ba0-0945-464a-b215-873296710c8c", - "handle": "cucumber_fan92" - } - } - ] + "errors": [ + { + "message": "An error occurred when fetching the tag" } - } + ] }, "matchingRules": { - "$.body.data.topic.id": { - "match": "type" - }, - "$.body.data.topic.title": { - "match": "type" - }, - "$.body.data.topic.updated_at": { - "match": "type" - }, - "$.body.data.topic.ttl": { - "match": "type" + "$.body.errors": { + "min": 1 }, - "$.body.data.topic.forum.id": { + "$.body.errors[*].*": { "match": "type" }, - "$.body.data.topic.forum.glyph": { + "$.body.errors[*].message": { "match": "type" - }, - "$.body.data.topic.forum.label": { - "match": "type" - }, - "$.body.data.topic.tags": { - "min": 1 - }, - "$.body.data.topic.tags[*].*": { + } + } + } + }, + { + "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": "8f75eba5-6989-4dd3-b466-e464546ce374" + } + }, + "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.topic.tags[*].id": { + "$.body.data.post.id": { "match": "type" }, - "$.body.data.topic.tags[*].weight": { + "$.body.data.post.text": { "match": "type" }, - "$.body.data.topic.posts": { - "min": 1 - }, - "$.body.data.topic.posts[*].*": { + "$.body.data.post.created_at": { "match": "type" }, - "$.body.data.topic.posts[*].id": { + "$.body.data.post.author": { "match": "type" }, - "$.body.data.topic.posts[*].text": { + "$.body.data.post.author.id": { "match": "type" }, - "$.body.data.topic.posts[*].created_at": { + "$.body.data.post.author.handle": { "match": "type" }, - "$.body.data.topic.posts[*].author": { + "$.body.data.post.topic": { "match": "type" }, - "$.body.data.topic.posts[*].author.id": { + "$.body.data.post.topic.id": { "match": "type" }, - "$.body.data.topic.posts[*].author.handle": { + "$.body.data.post.topic.title": { "match": "type" } } } }, { - "description": "a request to get a single topic", + "description": "a request to get a single post", "providerState": "there's no data", "request": { "method": "POST", @@ -681,16 +872,16 @@ "content-type": "application/json" }, "body": { - "operationName": "GetTopic", - "query": "query GetTopic($id: ID!) {\n topic(id: $id) {\n id\n title\n updated_at\n ttl\n forum {\n id\n glyph\n label\n __typename\n }\n tags {\n id\n weight\n __typename\n }\n posts {\n id\n text\n created_at\n author {\n id\n handle\n __typename\n }\n __typename\n }\n __typename\n }\n }", + "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": "0b58959d-d448-4a4e-84b6-35e5ac0028d1" + "id": "8f75eba5-6989-4dd3-b466-e464546ce374" } }, "matchingRules": { "$.body.query": { "match": "regex", - "regex": "query\\s*GetTopic\\(\\$id:\\s*ID!\\)\\s*\\{\\s*topic\\(id:\\s*\\$id\\)\\s*\\{\\s*id\\s*title\\s*updated_at\\s*ttl\\s*forum\\s*\\{\\s*id\\s*glyph\\s*label\\s*__typename\\s*\\}\\s*tags\\s*\\{\\s*id\\s*weight\\s*__typename\\s*\\}\\s*posts\\s*\\{\\s*id\\s*text\\s*created_at\\s*author\\s*\\{\\s*id\\s*handle\\s*__typename\\s*\\}\\s*__typename\\s*\\}\\s*__typename\\s*\\}\\s*\\}" + "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*\\}" } } }, @@ -701,14 +892,14 @@ }, "body": { "data": { - "topic": null + "post": null } } } }, { - "description": "a request to get a single topic", - "providerState": "there's an error", + "description": "a request to get a single post", + "providerState": "there's a server error", "request": { "method": "POST", "path": "/graphql", @@ -716,16 +907,16 @@ "content-type": "application/json" }, "body": { - "operationName": "GetTopic", - "query": "query GetTopic($id: ID!) {\n topic(id: $id) {\n id\n title\n updated_at\n ttl\n forum {\n id\n glyph\n label\n __typename\n }\n tags {\n id\n weight\n __typename\n }\n posts {\n id\n text\n created_at\n author {\n id\n handle\n __typename\n }\n __typename\n }\n __typename\n }\n }", + "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": "0b58959d-d448-4a4e-84b6-35e5ac0028d1" + "id": "8f75eba5-6989-4dd3-b466-e464546ce374" } }, "matchingRules": { "$.body.query": { "match": "regex", - "regex": "query\\s*GetTopic\\(\\$id:\\s*ID!\\)\\s*\\{\\s*topic\\(id:\\s*\\$id\\)\\s*\\{\\s*id\\s*title\\s*updated_at\\s*ttl\\s*forum\\s*\\{\\s*id\\s*glyph\\s*label\\s*__typename\\s*\\}\\s*tags\\s*\\{\\s*id\\s*weight\\s*__typename\\s*\\}\\s*posts\\s*\\{\\s*id\\s*text\\s*created_at\\s*author\\s*\\{\\s*id\\s*handle\\s*__typename\\s*\\}\\s*__typename\\s*\\}\\s*__typename\\s*\\}\\s*\\}" + "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*\\}" } } }, @@ -734,6 +925,54 @@ "headers": { } } + }, + { + "description": "a request to get a single post", + "providerState": "there's an error in the response", + "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": "8f75eba5-6989-4dd3-b466-e464546ce374" + } + }, + "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": { + "errors": [ + { + "message": "An error occurred when fetching the post" + } + ] + }, + "matchingRules": { + "$.body.errors": { + "min": 1 + }, + "$.body.errors[*].*": { + "match": "type" + }, + "$.body.errors[*].message": { + "match": "type" + } + } + } } ], "metadata": { |