mirror of
https://github.com/Orange-OpenSource/hurl.git
synced 2024-12-22 18:41:33 +03:00
Harden integration test on GraphQL.
This test could have detected regression on header parsing.
This commit is contained in:
parent
48188205c4
commit
b9dc82d22c
@ -1,4 +1,5 @@
|
||||
curl -H 'Content-Type: application/json' --data '{"query":"{\n allFilms {\n films {\n title\n director\n releaseDate\n }\n }\n}"}' 'http://localhost:8000/graphql'
|
||||
curl -H 'Content-Type: application/json' --data '{"query":"{\n allFilms {\n films {\n title\n director\n releaseDate\n }\n }\n}"}' 'http://localhost:8000/graphql'
|
||||
curl -H 'Content-Type: application/json' --data '{"query":"query Query {\n allFilms {\n films {\n title\n director\n releaseDate\n }\n }\n}"}' 'http://localhost:8000/graphql'
|
||||
curl -H 'Content-Type: application/json' --data '{"query":"query Person($id: ID!) {\n person(id: $id) {\n name\n }\n}","variables":"{\n \"id\": \"cGVvcGxlOjQ=\"\n}"}' 'http://localhost:8000/graphql'
|
||||
curl -H 'Content-Type: application/json' --data '{"query":"query Person($id: ID!) {\n person(id: $id) {\n name\n }\n}","variables":"{\n \"id\": \"cGVvcGxlOjQ=\"\n}"}' 'http://localhost:8000/graphql'
|
||||
|
@ -23,6 +23,16 @@
|
||||
<span class="line"><span class="query-type">jsonpath</span> <span class="string">"$.data.allFilms.films[2].title"</span> <span class="predicate-type">==</span> <span class="string">"Return of the Jedi"</span></span>
|
||||
</span></span><span class="hurl-entry"><span class="request"><span class="line"></span>
|
||||
<span class="line"></span>
|
||||
<span class="line"></span><span class="comment"># Equivalent syntax by posting a JSON body</span>
|
||||
<span class="line"><span class="method">POST</span> <span class="url">http://localhost:8000/graphql</span></span>
|
||||
<span class="line"><span class="string">Content-Type</span><span>:</span> <span class="string">application/json</span></span>
|
||||
<span class="json"><span class="line">{"query":"{\n allFilms {\n films {\n title\n director\n releaseDate\n }\n }\n}"}</span></span>
|
||||
</span><span class="response"><span class="line"></span>
|
||||
<span class="line"><span class="version">HTTP</span> <span class="number">200</span></span>
|
||||
<span class="line section-header">[Asserts]</span>
|
||||
<span class="line"><span class="query-type">jsonpath</span> <span class="string">"$.data.allFilms.films"</span> <span class="filter-type">count</span> <span class="predicate-type">==</span> <span class="number">6</span></span>
|
||||
</span></span><span class="hurl-entry"><span class="request"><span class="line"></span>
|
||||
<span class="line"></span>
|
||||
<span class="line"></span><span class="comment"># Full syntax for query</span>
|
||||
<span class="line"><span class="method">POST</span> <span class="url">http://localhost:8000/graphql</span></span>
|
||||
<span class="multiline"><span class="line">```graphql</span>
|
||||
@ -41,6 +51,7 @@
|
||||
<span class="line section-header">[Asserts]</span>
|
||||
<span class="line"><span class="query-type">jsonpath</span> <span class="string">"$.data.allFilms.films"</span> <span class="filter-type">count</span> <span class="predicate-type">==</span> <span class="number">6</span></span>
|
||||
</span></span><span class="hurl-entry"><span class="request"><span class="line"></span>
|
||||
<span class="line"></span>
|
||||
<span class="line"></span><span class="comment"># Query with variables:</span>
|
||||
<span class="line"><span class="method">POST</span> <span class="url">http://localhost:8000/graphql</span></span>
|
||||
<span class="multiline"><span class="line">```graphql</span>
|
||||
|
@ -23,6 +23,16 @@ jsonpath "$.data.allFilms.films[1].title" == "The Empire Strikes Back"
|
||||
jsonpath "$.data.allFilms.films[2].title" == "Return of the Jedi"
|
||||
|
||||
|
||||
# Equivalent syntax by posting a JSON body
|
||||
POST http://localhost:8000/graphql
|
||||
Content-Type: application/json
|
||||
{"query":"{\n allFilms {\n films {\n title\n director\n releaseDate\n }\n }\n}"}
|
||||
|
||||
HTTP 200
|
||||
[Asserts]
|
||||
jsonpath "$.data.allFilms.films" count == 6
|
||||
|
||||
|
||||
# Full syntax for query
|
||||
POST http://localhost:8000/graphql
|
||||
```graphql
|
||||
@ -41,6 +51,7 @@ HTTP 200
|
||||
[Asserts]
|
||||
jsonpath "$.data.allFilms.films" count == 6
|
||||
|
||||
|
||||
# Query with variables:
|
||||
POST http://localhost:8000/graphql
|
||||
```graphql
|
||||
|
@ -1 +1 @@
|
||||
{"entries":[{"request":{"method":"POST","url":"http://localhost:8000/graphql","body":{"type":"graphql","value":"{\n allFilms {\n films {\n title\n director\n releaseDate\n }\n }\n}\n"}},"response":{"status":200,"asserts":[{"query":{"type":"jsonpath","expr":"$.data.allFilms.films"},"filters":[{"type":"count"}],"predicate":{"type":"equal","value":6}},{"query":{"type":"jsonpath","expr":"$.data.allFilms.films[0].title"},"predicate":{"type":"equal","value":"A New Hope"}},{"query":{"type":"jsonpath","expr":"$.data.allFilms.films[0].director"},"predicate":{"type":"equal","value":"George Lucas"}},{"query":{"type":"jsonpath","expr":"$.data.allFilms.films[0].releaseDate"},"predicate":{"type":"equal","value":"1977-05-25"}},{"query":{"type":"jsonpath","expr":"$.data.allFilms.films[0].openingCrawl"},"predicate":{"not":true,"type":"exist"}},{"query":{"type":"jsonpath","expr":"$.data.allFilms.films[1].title"},"predicate":{"type":"equal","value":"The Empire Strikes Back"}},{"query":{"type":"jsonpath","expr":"$.data.allFilms.films[2].title"},"predicate":{"type":"equal","value":"Return of the Jedi"}}]}},{"request":{"method":"POST","url":"http://localhost:8000/graphql","body":{"type":"graphql","value":"query Query {\n allFilms {\n films {\n title\n director\n releaseDate\n }\n }\n}\n"}},"response":{"status":200,"asserts":[{"query":{"type":"jsonpath","expr":"$.data.allFilms.films"},"filters":[{"type":"count"}],"predicate":{"type":"equal","value":6}}]}},{"request":{"method":"POST","url":"http://localhost:8000/graphql","body":{"type":"graphql","value":"query Person($id: ID!) {\n person(id: $id) {\n name\n }\n}\n\nvariables {\n \"id\": \"cGVvcGxlOjQ=\"\n}\n"}},"response":{"status":200,"asserts":[{"query":{"type":"jsonpath","expr":"$.data.person.name"},"predicate":{"type":"equal","value":"Darth Vader"}}]}},{"request":{"method":"POST","url":"http://localhost:8000/graphql","body":{"type":"graphql","value":"query Person($id: ID!) {\n person(id: $id) {\n name\n }\n}\n\nvariables {\n \"id\": \"{{id}}\"\n}\n"}},"response":{"status":200,"asserts":[{"query":{"type":"jsonpath","expr":"$.data.person.name"},"predicate":{"type":"equal","value":"Darth Vader"}}]}}]}
|
||||
{"entries":[{"request":{"method":"POST","url":"http://localhost:8000/graphql","body":{"type":"graphql","value":"{\n allFilms {\n films {\n title\n director\n releaseDate\n }\n }\n}\n"}},"response":{"status":200,"asserts":[{"query":{"type":"jsonpath","expr":"$.data.allFilms.films"},"filters":[{"type":"count"}],"predicate":{"type":"equal","value":6}},{"query":{"type":"jsonpath","expr":"$.data.allFilms.films[0].title"},"predicate":{"type":"equal","value":"A New Hope"}},{"query":{"type":"jsonpath","expr":"$.data.allFilms.films[0].director"},"predicate":{"type":"equal","value":"George Lucas"}},{"query":{"type":"jsonpath","expr":"$.data.allFilms.films[0].releaseDate"},"predicate":{"type":"equal","value":"1977-05-25"}},{"query":{"type":"jsonpath","expr":"$.data.allFilms.films[0].openingCrawl"},"predicate":{"not":true,"type":"exist"}},{"query":{"type":"jsonpath","expr":"$.data.allFilms.films[1].title"},"predicate":{"type":"equal","value":"The Empire Strikes Back"}},{"query":{"type":"jsonpath","expr":"$.data.allFilms.films[2].title"},"predicate":{"type":"equal","value":"Return of the Jedi"}}]}},{"request":{"method":"POST","url":"http://localhost:8000/graphql","headers":[{"name":"Content-Type","value":"application/json"}],"body":{"type":"json","value":{"query":"{\n allFilms {\n films {\n title\n director\n releaseDate\n }\n }\n}"}}},"response":{"status":200,"asserts":[{"query":{"type":"jsonpath","expr":"$.data.allFilms.films"},"filters":[{"type":"count"}],"predicate":{"type":"equal","value":6}}]}},{"request":{"method":"POST","url":"http://localhost:8000/graphql","body":{"type":"graphql","value":"query Query {\n allFilms {\n films {\n title\n director\n releaseDate\n }\n }\n}\n"}},"response":{"status":200,"asserts":[{"query":{"type":"jsonpath","expr":"$.data.allFilms.films"},"filters":[{"type":"count"}],"predicate":{"type":"equal","value":6}}]}},{"request":{"method":"POST","url":"http://localhost:8000/graphql","body":{"type":"graphql","value":"query Person($id: ID!) {\n person(id: $id) {\n name\n }\n}\n\nvariables {\n \"id\": \"cGVvcGxlOjQ=\"\n}\n"}},"response":{"status":200,"asserts":[{"query":{"type":"jsonpath","expr":"$.data.person.name"},"predicate":{"type":"equal","value":"Darth Vader"}}]}},{"request":{"method":"POST","url":"http://localhost:8000/graphql","body":{"type":"graphql","value":"query Person($id: ID!) {\n person(id: $id) {\n name\n }\n}\n\nvariables {\n \"id\": \"{{id}}\"\n}\n"}},"response":{"status":200,"asserts":[{"query":{"type":"jsonpath","expr":"$.data.person.name"},"predicate":{"type":"equal","value":"Darth Vader"}}]}}]}
|
||||
|
Loading…
Reference in New Issue
Block a user