diff options
| author | Ruben Beltran del Rio <ruben@unlimited.pizza> | 2021-05-02 19:53:10 +0200 |
|---|---|---|
| committer | Ruben Beltran del Rio <ruben@unlimited.pizza> | 2021-05-02 19:53:10 +0200 |
| commit | b15225c9dff2864ee774a0ab1dcf19d9353ec10b (patch) | |
| tree | c492bdda4ae0f1471a9fc8fda6583703cb227269 /pacts | |
| parent | 605230e032808155d62ed773cc551b5ae1847a5f (diff) | |
Add posts store pact test
Diffstat (limited to 'pacts')
| -rw-r--r-- | pacts/forumclient-forumserver.json (renamed from pacts/forumsstore-forumapiserver.json) | 155 |
1 files changed, 149 insertions, 6 deletions
diff --git a/pacts/forumsstore-forumapiserver.json b/pacts/forumclient-forumserver.json index c0e784b..b1c7fcb 100644 --- a/pacts/forumsstore-forumapiserver.json +++ b/pacts/forumclient-forumserver.json @@ -1,14 +1,157 @@ { "consumer": { - "name": "ForumsStore" + "name": "ForumClient" }, "provider": { - "name": "ForumAPIServer" + "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 forums", + "providerState": "there's data", "request": { "method": "POST", "path": "/graphql", @@ -69,7 +212,7 @@ }, { "description": "a request to get a single forum", - "providerState": "there's forums", + "providerState": "there's data", "request": { "method": "POST", "path": "/graphql", @@ -149,7 +292,7 @@ }, { "description": "a request to list the forums", - "providerState": "there's no forums", + "providerState": "there's no data", "request": { "method": "POST", "path": "/graphql", @@ -185,7 +328,7 @@ }, { "description": "a request to get a single forum", - "providerState": "there's no forums", + "providerState": "there's no data", "request": { "method": "POST", "path": "/graphql", |