mirror of
https://github.com/Orange-OpenSource/hurl.git
synced 2024-12-24 03:21:40 +03:00
71 lines
9.6 KiB
HTML
71 lines
9.6 KiB
HTML
<pre><code class="language-hurl"><span class="hurl-entry"><span class="request"><span class="line"><span class="method">GET</span> <span class="url">http://localhost:8000/assert-json</span></span>
|
|
</span><span class="response"><span class="line"><span class="version">HTTP/1.0</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">"$.count"</span> <span class="predicate-type">==</span> <span class="number">5</span></span>
|
|
<span class="line"><span class="query-type">jsonpath</span> <span class="string">"$.count"</span> <span class="predicate-type">==</span> <span class="number">5.0</span></span>
|
|
<span class="line"><span class="query-type">jsonpath</span> <span class="string">"$.count"</span> <span class="predicate-type">equals</span> <span class="number">5</span></span>
|
|
<span class="line"><span class="query-type">jsonpath</span> <span class="string">"$.count"</span> <span class="predicate-type">!=</span> <span class="number">4</span></span>
|
|
<span class="line"><span class="query-type">jsonpath</span> <span class="string">"$.count"</span> <span class="not">not</span> <span class="predicate-type">equals</span> <span class="number">4</span></span>
|
|
<span class="line"><span class="query-type">jsonpath</span> <span class="string">"$.count"</span> <span class="predicate-type">></span> <span class="number">1</span></span>
|
|
<span class="line"><span class="query-type">jsonpath</span> <span class="string">"$.count"</span> <span class="predicate-type">></span> <span class="number">1.0</span></span>
|
|
<span class="line"><span class="query-type">jsonpath</span> <span class="string">"$.count"</span> <span class="predicate-type">greaterThan</span> <span class="number">1.0</span></span>
|
|
<span class="line"><span class="query-type">jsonpath</span> <span class="string">"$.success"</span> <span class="predicate-type">==</span> <span class="boolean">false</span></span>
|
|
<span class="line"><span class="query-type">jsonpath</span> <span class="string">"$.success"</span> <span class="predicate-type">!=</span> <span class="null">null</span></span>
|
|
<span class="line"><span class="query-type">jsonpath</span> <span class="string">"$.success"</span> <span class="predicate-type">exists</span></span>
|
|
<span class="line"><span class="query-type">jsonpath</span> <span class="string">"$.success"</span> <span class="predicate-type">isBoolean</span></span>
|
|
<span class="line"><span class="query-type">jsonpath</span> <span class="string">"$.errors"</span> <span class="subquery-type">count</span> <span class="predicate-type">==</span> <span class="number">2</span></span>
|
|
<span class="line"><span class="query-type">jsonpath</span> <span class="string">"$.errors"</span> <span class="predicate-type">isCollection</span></span>
|
|
<span class="line"><span class="query-type">jsonpath</span> <span class="string">"$.warnings"</span> <span class="subquery-type">count</span> <span class="predicate-type">==</span> <span class="number">0</span></span>
|
|
<span class="line"><span class="query-type">jsonpath</span> <span class="string">"$.toto"</span> <span class="not">not</span> <span class="predicate-type">exists</span></span>
|
|
<span class="line"><span class="query-type">jsonpath</span> <span class="string">"$.warnings"</span> <span class="predicate-type">exists</span></span>
|
|
<span class="line"><span class="query-type">jsonpath</span> <span class="string">"$.warnings"</span> <span class="predicate-type">exists</span></span>
|
|
<span class="line"><span class="query-type">jsonpath</span> <span class="string">"$.errors[0]"</span> <span class="predicate-type">exists</span></span>
|
|
<span class="line"><span class="query-type">jsonpath</span> <span class="string">"$.errors[0]"</span> <span class="predicate-type">isCollection</span></span>
|
|
<span class="line"><span class="query-type">jsonpath</span> <span class="string">"$.errors[0].id"</span> <span class="predicate-type">==</span> <span class="string">"error1"</span></span>
|
|
<span class="line"><span class="query-type">jsonpath</span> <span class="string">"$.errors[0]['id']"</span> <span class="predicate-type">==</span> <span class="string">"error1"</span></span>
|
|
<span class="line"><span class="query-type">jsonpath</span> <span class="string">"$.errors[*].id"</span> <span class="predicate-type">includes</span> <span class="string">"error1"</span></span>
|
|
<span class="line"><span class="query-type">jsonpath</span> <span class="string">"$.errors[?(@.id=='error1')].id"</span> <span class="predicate-type">==</span> <span class="string">"error1"</span></span>
|
|
<span class="line"><span class="query-type">jsonpath</span> <span class="string">"$.duration"</span> <span class="predicate-type">==</span> <span class="number">1.5</span></span>
|
|
<span class="line"><span class="query-type">jsonpath</span> <span class="string">"$.duration"</span> <span class="predicate-type"><=</span> <span class="number">2.0</span></span>
|
|
<span class="line"><span class="query-type">jsonpath</span> <span class="string">"$.duration"</span> <span class="predicate-type"><</span> <span class="number">2</span></span>
|
|
<span class="line"><span class="query-type">jsonpath</span> <span class="string">"$.duration"</span> <span class="predicate-type">lessThanOrEquals</span> <span class="number">2.0</span></span>
|
|
<span class="line"><span class="query-type">jsonpath</span> <span class="string">"$.duration"</span> <span class="predicate-type">lessThan</span> <span class="number">2</span></span>
|
|
<span class="line"><span class="query-type">jsonpath</span> <span class="string">"$.duration"</span> <span class="predicate-type">isFloat</span></span>
|
|
<span class="line"><span class="query-type">jsonpath</span> <span class="string">"$.duration"</span> <span class="not">not</span> <span class="predicate-type">isInteger</span></span>
|
|
<span class="line"><span class="query-type">jsonpath</span> <span class="string">"$.nullable"</span> <span class="predicate-type">==</span> <span class="null">null</span></span>
|
|
<span class="line"></span>
|
|
<span class="json"><span class="line">{</span>
|
|
<span class="line"> "count": 5,</span>
|
|
<span class="line"> "success": false,</span>
|
|
<span class="line"> "errors": [{"id":"error1"},{"id":"error2"}],</span>
|
|
<span class="line"> "warnings": [],</span>
|
|
<span class="line"> "duration": 1.5,</span>
|
|
<span class="line"> "tags": ["test"],</span>
|
|
<span class="line"> "nullable": null</span>
|
|
<span class="line">}</span></span>
|
|
</span></span><span class="hurl-entry"><span class="request"><span class="line"></span>
|
|
<span class="line"><span class="method">GET</span> <span class="url">http://localhost:8000/assert-json/index</span></span>
|
|
</span><span class="response"><span class="line"><span class="version">HTTP/1.0</span> <span class="number">200</span></span>
|
|
<span class="line section-header">[Captures]</span>
|
|
<span class="line"><span class="name">index</span><span>:</span> <span class="query-type">body</span></span>
|
|
</span></span><span class="hurl-entry"><span class="request"><span class="line"></span>
|
|
<span class="line"><span class="method">GET</span> <span class="url">http://localhost:8000/assert-json</span></span>
|
|
</span><span class="response"><span class="line"><span class="version">HTTP/1.0</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">"$.errors[{{index}}].id"</span> <span class="predicate-type">==</span> <span class="string">"error2"</span></span>
|
|
<span class="line"><span class="query-type">jsonpath</span> <span class="string">"$.tags"</span> <span class="predicate-type">includes</span> <span class="string">"test"</span></span>
|
|
<span class="line"><span class="query-type">jsonpath</span> <span class="string">"$.tags"</span> <span class="not">not</span> <span class="predicate-type">includes</span> <span class="string">"prod"</span></span>
|
|
<span class="line"><span class="query-type">jsonpath</span> <span class="string">"$.tags"</span> <span class="not">not</span> <span class="predicate-type">includes</span> <span class="null">null</span></span>
|
|
</span></span><span class="hurl-entry"><span class="request"><span class="line"></span>
|
|
<span class="line"></span>
|
|
<span class="line"><span class="method">GET</span> <span class="url">http://localhost:8000/assert-json/list</span></span>
|
|
</span><span class="response"><span class="line"><span class="version">HTTP/1.0</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">"$"</span> <span class="subquery-type">count</span> <span class="predicate-type">==</span> <span class="number">2</span></span>
|
|
<span class="line"><span class="query-type">jsonpath</span> <span class="string">"$.[0].name"</span> <span class="predicate-type">==</span> <span class="string">"Bob"</span></span>
|
|
<span class="line"><span class="query-type">jsonpath</span> <span class="string">"$[0].name"</span> <span class="predicate-type">==</span> <span class="string">"Bob"</span></span>
|
|
</span></span><span class="hurl-entry"><span class="request"><span class="line"></span>
|
|
<span class="line"><span class="method">GET</span> <span class="url">http://localhost:8000/assert-json/filter</span></span>
|
|
</span><span class="response"><span class="line"><span class="version">HTTP/1.0</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">"$.fruit[?(@.price.US==200)].name"</span> <span class="predicate-type">equals</span> <span class="string">"grape"</span></span></span></span></code></pre> |