mirror of
https://github.com/Orange-OpenSource/hurl.git
synced 2024-12-24 03:21:40 +03:00
153 lines
9.9 KiB
HTML
153 lines
9.9 KiB
HTML
<pre><code class="language-hurl"><span class="hurl-entry"><span class="request"><span class="line"></span><span class="comment"># In each request, we sent a multiline body and get</span>
|
|
<span class="line"></span><span class="comment"># the same body as response. Request body is tested server side</span>
|
|
<span class="line"></span><span class="comment"># and we assert the response here.</span>
|
|
<span class="line"></span>
|
|
<span class="line"><span class="method">POST</span> <span class="url">http://localhost:8000/multilines/plain-text</span></span>
|
|
<span class="multiline"><span class="line">```</span>
|
|
<span class="line">line1</span>
|
|
<span class="line">line2</span>
|
|
<span class="line">line3</span>
|
|
<span class="line">```</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"></span><span class="comment"># Different ways of testing body response:</span>
|
|
<span class="line"></span><span class="comment"># with explicit asserts:</span>
|
|
<span class="line"><span class="section-header">[Asserts]</span></span>
|
|
<span class="line"><span class="query-type">body</span> <span class="predicate-type">==</span> <span class="string">"line1\nline2\nline3\n"</span></span>
|
|
<span class="line"><span class="query-type">body</span> <span class="predicate-type">==</span> <span class="multiline"><span class="line">```</span>
|
|
<span class="line">line1</span>
|
|
<span class="line">line2</span>
|
|
<span class="line">line3</span>
|
|
<span class="line">```</span></span></span>
|
|
<span class="line"></span><span class="comment"># Or we can just test the body (implicit assert):</span>
|
|
<span class="multiline"><span class="line">```</span>
|
|
<span class="line">line1</span>
|
|
<span class="line">line2</span>
|
|
<span class="line">line3</span>
|
|
<span class="line">```</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">POST</span> <span class="url">http://localhost:8000/multilines/json</span></span>
|
|
<span class="multiline"><span class="line">```json</span>
|
|
<span class="line">{</span>
|
|
<span class="line"> "foo": "bar"</span>
|
|
<span class="line"> "baz": 123456</span>
|
|
<span class="line">}</span>
|
|
<span class="line">```</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"></span><span class="comment"># Different ways of testing body response:</span>
|
|
<span class="line"></span><span class="comment"># with explicit asserts:</span>
|
|
<span class="line"><span class="section-header">[Asserts]</span></span>
|
|
<span class="line"><span class="query-type">body</span> <span class="predicate-type">==</span> <span class="string">"{\n \"foo\": \"bar\"\n \"baz\": 123456\n}\n"</span></span>
|
|
<span class="line"><span class="query-type">body</span> <span class="predicate-type">==</span> <span class="multiline"><span class="line">```json</span>
|
|
<span class="line">{</span>
|
|
<span class="line"> "foo": "bar"</span>
|
|
<span class="line"> "baz": 123456</span>
|
|
<span class="line">}</span>
|
|
<span class="line">```</span></span></span>
|
|
<span class="line"></span><span class="comment"># Or we can just test the body (implicit assert):</span>
|
|
<span class="multiline"><span class="line">```json</span>
|
|
<span class="line">{</span>
|
|
<span class="line"> "foo": "bar"</span>
|
|
<span class="line"> "baz": 123456</span>
|
|
<span class="line">}</span>
|
|
<span class="line">```</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="line"><span class="method">POST</span> <span class="url">http://localhost:8000/multilines/xml</span></span>
|
|
<span class="multiline"><span class="line">```xml</span>
|
|
<span class="line"><?xml version="1.0"?></span>
|
|
<span class="line"><catalog></span>
|
|
<span class="line"> <book id="bk101"></span>
|
|
<span class="line"> <author>Gambardella, Matthew</author></span>
|
|
<span class="line"> <title>XML Developer's Guide</title></span>
|
|
<span class="line"> <genre>Computer</genre></span>
|
|
<span class="line"> <price>44.95</price></span>
|
|
<span class="line"> <publish_date>2000-10-01</publish_date></span>
|
|
<span class="line"> <description>An in-depth look at creating applications</span>
|
|
<span class="line"> with XML.</description></span>
|
|
<span class="line"> </book></span>
|
|
<span class="line"></catalog></span>
|
|
<span class="line">```</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"></span><span class="comment"># Different ways of testing body response:</span>
|
|
<span class="line"></span><span class="comment"># with explicit asserts:</span>
|
|
<span class="line"><span class="section-header">[Asserts]</span></span>
|
|
<span class="line"><span class="query-type">body</span> <span class="predicate-type">==</span> <span class="string">"<?xml version=\"1.0\"?>\n<catalog>\n <book id=\"bk101\">\n <author>Gambardella, Matthew</author>\n <title>XML Developer's Guide</title>\n <genre>Computer</genre>\n <price>44.95</price>\n <publish_date>2000-10-01</publish_date>\n <description>An in-depth look at creating applications\n with XML.</description>\n </book>\n</catalog>\n"</span></span>
|
|
<span class="line"><span class="query-type">body</span> <span class="predicate-type">==</span> <span class="multiline"><span class="line">```xml</span>
|
|
<span class="line"><?xml version="1.0"?></span>
|
|
<span class="line"><catalog></span>
|
|
<span class="line"> <book id="bk101"></span>
|
|
<span class="line"> <author>Gambardella, Matthew</author></span>
|
|
<span class="line"> <title>XML Developer's Guide</title></span>
|
|
<span class="line"> <genre>Computer</genre></span>
|
|
<span class="line"> <price>44.95</price></span>
|
|
<span class="line"> <publish_date>2000-10-01</publish_date></span>
|
|
<span class="line"> <description>An in-depth look at creating applications</span>
|
|
<span class="line"> with XML.</description></span>
|
|
<span class="line"> </book></span>
|
|
<span class="line"></catalog></span>
|
|
<span class="line">```</span></span></span>
|
|
<span class="line"></span><span class="comment"># Or we can just test the body (implicit assert):</span>
|
|
<span class="multiline"><span class="line">```xml</span>
|
|
<span class="line"><?xml version="1.0"?></span>
|
|
<span class="line"><catalog></span>
|
|
<span class="line"> <book id="bk101"></span>
|
|
<span class="line"> <author>Gambardella, Matthew</author></span>
|
|
<span class="line"> <title>XML Developer's Guide</title></span>
|
|
<span class="line"> <genre>Computer</genre></span>
|
|
<span class="line"> <price>44.95</price></span>
|
|
<span class="line"> <publish_date>2000-10-01</publish_date></span>
|
|
<span class="line"> <description>An in-depth look at creating applications</span>
|
|
<span class="line"> with XML.</description></span>
|
|
<span class="line"> </book></span>
|
|
<span class="line"></catalog></span>
|
|
<span class="line">```</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="line"><span class="method">POST</span> <span class="url">http://localhost:8000/multilines/graphql</span></span>
|
|
<span class="multiline"><span class="line">```graphql</span>
|
|
<span class="line">{</span>
|
|
<span class="line"> hero {</span>
|
|
<span class="line"> name</span>
|
|
<span class="line"> # Queries can have comments!</span>
|
|
<span class="line"> friends {</span>
|
|
<span class="line"> name</span>
|
|
<span class="line"> }</span>
|
|
<span class="line"> }</span>
|
|
<span class="line">}</span>
|
|
<span class="line">```</span></span>
|
|
</span><span class="response"><span class="line"><span class="version">HTTP</span> <span class="number">200</span></span>
|
|
<span class="line"></span><span class="comment"># Different ways of testing body response:</span>
|
|
<span class="line"></span><span class="comment"># with explicit asserts:</span>
|
|
<span class="line"><span class="section-header">[Asserts]</span></span>
|
|
<span class="line"><span class="query-type">body</span> <span class="predicate-type">==</span> <span class="string">"{\"query\":\"{\\n hero {\\n name\\n # Queries can have comments!\\n friends {\\n name\\n }\\n }\\n}\"}"</span></span>
|
|
<span class="line"><span class="query-type">body</span> <span class="predicate-type">==</span> <span class="multiline"><span class="line">```graphql</span>
|
|
<span class="line">{</span>
|
|
<span class="line"> hero {</span>
|
|
<span class="line"> name</span>
|
|
<span class="line"> # Queries can have comments!</span>
|
|
<span class="line"> friends {</span>
|
|
<span class="line"> name</span>
|
|
<span class="line"> }</span>
|
|
<span class="line"> }</span>
|
|
<span class="line">}</span>
|
|
<span class="line">```</span></span></span>
|
|
<span class="line"></span><span class="comment"># Or we can just test the body (implicit assert):</span>
|
|
<span class="multiline"><span class="line">```graphql</span>
|
|
<span class="line">{</span>
|
|
<span class="line"> hero {</span>
|
|
<span class="line"> name</span>
|
|
<span class="line"> # Queries can have comments!</span>
|
|
<span class="line"> friends {</span>
|
|
<span class="line"> name</span>
|
|
<span class="line"> }</span>
|
|
<span class="line"> }</span>
|
|
<span class="line">}</span>
|
|
<span class="line">```</span></span>
|
|
</span></span></code></pre>
|