hurl/integration/tests_ok/variables.html

56 lines
5.3 KiB
HTML
Raw Normal View History

2022-09-02 11:50:43 +03:00
<pre><code class="language-hurl"><span class="hurl-entry"><span class="request"><span class="line"></span><span class="comment"># Variables can be set from:</span>
<span class="line"></span><span class="comment"># - an external properties file</span>
<span class="line"></span><span class="comment"># - at the command-line with the --variable option</span>
2022-09-07 20:12:25 +03:00
<span class="line"></span><span class="comment"># - with HURL_xxx environment variable</span>
2022-09-02 11:50:43 +03:00
<span class="line"></span><span class="comment"># - in the Hurl File in the [Options] section</span>
<span class="line"></span>
<span class="line"><span class="method">POST</span> <span class="url">http://localhost:8000/variables</span></span>
2023-04-17 14:05:34 +03:00
<span class="line"><span class="string">Name</span>: <span class="string">{{name}}</span></span>
<span class="line"><span class="string">Age</span>: <span class="string">{{age}}</span></span>
<span class="line"><span class="string">Height</span>: <span class="string">{{height}}</span></span>
<span class="line"><span class="string">Female</span>: <span class="string">{{female}}</span></span>
<span class="line"><span class="string">Id</span>: <span class="string">{{my-id}}</span></span>
2023-05-02 09:43:38 +03:00
<span class="line"><span class="string">A-Null</span>: <span class="string">{{a_null}}</span></span>
2023-04-17 14:05:34 +03:00
<span class="line"><span class="string">Country</span>: <span class="string">{{country}}</span></span>
<span class="line"><span class="string">Planet</span>: <span class="string">{{planet}}</span></span>
<span class="line"><span class="string">Galaxy</span>: <span class="string">{{galaxy}}</span></span>
2023-04-11 18:28:28 +03:00
<span class="line"><span class="section-header">[Options]</span></span>
2023-04-17 14:05:34 +03:00
<span class="line"><span class="string">variable</span>: country=<span class="string">Italy</span></span>
<span class="line"><span class="string">variable</span>: planet=<span class="string">The Earth</span></span>
2021-09-21 07:36:53 +03:00
<span class="json"><span class="line">{</span>
<span class="line"> "name": "{{name}}",</span>
<span class="line"> "age": {{age}},</span>
<span class="line"> "height": {{height}},</span>
<span class="line"> "female": {{female}},</span>
<span class="line"> "id": "{{my-id}}",</span>
2022-09-02 11:50:43 +03:00
<span class="line"> "a_null": {{a_null}},</span>
<span class="line"> "country": "{{country}}",</span>
<span class="line"> "planet": "{{planet}}",</span>
<span class="line"> "galaxy": "{{galaxy}}"</span>
2021-09-21 07:36:53 +03:00
<span class="line">}</span></span>
</span><span class="response"><span class="line"></span>
2022-11-11 16:25:00 +03:00
<span class="line"><span class="version">HTTP</span> <span class="number">200</span></span>
2023-04-11 18:28:28 +03:00
<span class="line"><span class="section-header">[Asserts]</span></span>
<span class="line"><span class="query-type">variable</span> <span class="string">"name"</span> <span class="predicate-type">==</span> <span class="string">"Jennifer"</span></span>
<span class="line"><span class="query-type">variable</span> <span class="string">"female"</span> <span class="predicate-type">==</span> <span class="boolean">true</span></span>
<span class="line"><span class="query-type">variable</span> <span class="string">"age"</span> <span class="predicate-type">==</span> <span class="number">30</span></span>
<span class="line"><span class="query-type">variable</span> <span class="string">"height"</span> <span class="predicate-type">==</span> <span class="number">1.70</span></span>
<span class="line"><span class="query-type">variable</span> <span class="string">"a_null"</span> <span class="predicate-type">==</span> <span class="null">null</span></span>
<span class="line"><span class="query-type">variable</span> <span class="string">"my-id"</span> <span class="predicate-type">==</span> <span class="string">"123"</span></span>
<span class="line"><span class="query-type">variable</span> <span class="string">"country"</span> <span class="predicate-type">==</span> <span class="string">"Italy"</span></span>
<span class="line"><span class="query-type">variable</span> <span class="string">"planet"</span> <span class="predicate-type">==</span> <span class="string">"The Earth"</span></span>
<span class="line"><span class="query-type">variable</span> <span class="string">"galaxy"</span> <span class="predicate-type">==</span> <span class="string">"Milky Way"</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"># `country` and `planet` variable are still available</span>
<span class="line"></span><span class="comment"># for the next entries, even if they've been defined in the</span>
<span class="line"></span><span class="comment"># previous `[Options]` request section.</span>
<span class="line"><span class="method">GET</span> <span class="url">http://localhost:8000/variable/country</span></span>
</span><span class="response"><span class="line"><span class="version">HTTP</span> <span class="number">200</span></span>
<span class="line"><span class="string">`{{country}}`</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/variable/planet</span></span>
</span><span class="response"><span class="line"><span class="version">HTTP</span> <span class="number">200</span></span>
<span class="line"><span class="string">`{{planet}}`</span></span>
</span></span></code></pre>