Skip to content

Commit

Permalink
Update docs for 5.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jcamiel committed Aug 20, 2024
1 parent 57b54cf commit af7f58e
Show file tree
Hide file tree
Showing 18 changed files with 563 additions and 61 deletions.
5 changes: 3 additions & 2 deletions sites/build_home_samples.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ def make_home_samples():
[Asserts]
jsonpath "$.status" == "RUNNING" # Check the status code
jsonpath "$.tests" count == 25 # Check the number of items
jsonpath "$.id" matches /\d{4}/ # Check the format of the id
jsonpath "$.id" matches /\\d{4}/ # Check the format of the id
""",
),
Sample(
Expand Down Expand Up @@ -329,7 +329,7 @@ def make_home_samples():
certificate "Subject" == "CN=example.org"
certificate "Issuer" == "C=US, O=Let's Encrypt, CN=R3"
certificate "Expire-Date" daysAfterNow > 15
certificate "Serial-Number" matches /[\da-f]+/
certificate "Serial-Number" matches /[\\da-f]+/
""",
),
Sample(
Expand All @@ -339,6 +339,7 @@ def make_home_samples():
GET https://api.example.org/jobs/{{job_id}}
[Options]
retry: 10 # maximum number of retry, -1 for unlimited
retry-interval: 300ms
HTTP 200
[Asserts]
jsonpath "$.state" == "COMPLETED"
Expand Down
7 changes: 0 additions & 7 deletions sites/generate/build_jekyll_md.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,6 @@ def convert_to_jekyll(
) -> str:
text = path.read_text()

# Add asciinema div to index.md
if path == Path("../hurl/docs/home.md"):
text = text.replace(
'<a href="https://hurl.dev/player.html?id=hurl&speed=3"><img src="https://raw.githubusercontent.com/Orange-OpenSource/hurl/master/docs/assets/img/poster-hurl.png" width="100%" alt="Hurl Demo"/></a>',
'<div id="home-demo"></div>',
)

md_raw = parse_markdown(text)
md_escaped = MarkdownDoc()

Expand Down
9 changes: 9 additions & 0 deletions sites/hurl.dev/_data/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
- title: Reports
items:
- title: HTML Report
- title: JSON Report
- title: JUnit Report
- title: TAP Report
- title: JSON Output
Expand All @@ -99,9 +100,16 @@
path: /docs/running-tests.html
items:
- title: Use --test Option
items:
- title: Selecting Tests
- title: Debugging
items:
- title: Debug Logs
- title: HTTP Responses
- title: Generating Report
items:
- title: HTML Report
- title: JSON Report
- title: JUnit Report
- title: TAP Report
- title: Use Variables in Tests
Expand Down Expand Up @@ -140,6 +148,7 @@
- title: Cookie storage
- title: Redirects
- title: Retry
- title: Control flow
- title: Request
path: /docs/request.html
items:
Expand Down
2 changes: 1 addition & 1 deletion sites/hurl.dev/_docs/capturing-response.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ next_url: header "Location"

### URL capture

Capture the last fetched URL. This is most meaningful if you have told Hurl to follow redirection (see [`[Options]`section][options] or
Capture the last fetched URL. This is most meaningful if you have told Hurl to follow redirection (see [`[Options]` section][options] or
[`--location` option]). URL capture consists of a variable name, followed by a `:`, and the keyword `url`.

```hurl
Expand Down
59 changes: 54 additions & 5 deletions sites/hurl.dev/_docs/entry.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ every entry of a given file will follow redirection:
$ hurl --location foo.hurl
```

You can use an [`[Options]` section][options] to use option only for a specified option. For instance, in this Hurl file:
You can use an [`[Options]` section][options] to set option only for a specified request. For instance, in this Hurl file,
the second entry will follow location (so we can test the status code to be 200 instead of 301).

```hurl
GET https://google.fr
Expand All @@ -61,9 +62,7 @@ GET https://google.fr
HTTP 301
```

The second entry will follow location (so we can test the status code to be 200 instead of 301).

You can use it to log a specific entry:
You can use the `[Options]` section to log a specific entry:

```hurl
# ... previous entries
Expand Down Expand Up @@ -124,7 +123,7 @@ under flaky conditions. Asserts can be explicit (with an [`[Asserts]` section][a
Retries can be set globally for every request (see [`--retry`] and [`--retry-interval`]),
or activated on a particular request with an [`[Options]` section][options].

For example, in this Hurl file, first we create a new job, then we poll the new job until it's completed:
For example, in this Hurl file, first we create a new job then we poll the new job until it's completed:

{% raw %}
```hurl
Expand All @@ -141,20 +140,68 @@ jsonpath "$.state" == "RUNNING"
GET http://api.example.org/jobs/{{job_id}}
[Options]
retry: 10 # maximum number of retry, -1 for unlimited
retry-interval: 300ms
HTTP 200
[Asserts]
jsonpath "$.state" == "COMPLETED"
```
{% endraw %}


### Control flow

In `[Options]` section, `skip` and `repeat` can be used to control flow of execution:

- `skip: true/false` skip this request and execute the next one unconditionally,
- `repeat: N` loop the request N times. If there are assert or runtime errors, the requests execution is stopped.

```hurl
# This request will be played exactly 3 times
GET https://example.org/foo
[Options]
repeat: 3
HTTP 200
# This request is skipped
GET https://example.org/foo
[Options]
skip: true
HTTP 200
```

Additionally, a `delay` can be inserted between requests, to add a delay before execution of a request.

```hurl
# A 5 seconds delayed request
GET https://example.org/foo
[Options]
delay: 5s
HTTP 200
```

[`delay`] and [`repeat`] can also be used globally as command line options:

```shell
$ hurl --delay 500ms --repeat 3 foo.hurl
```



For complete reference, below is a diagram for the executed entries.

<div class="picture">
<img class="u-theme-light u-drop-shadow u-border u-max-width-100" src="{{ '/assets/img/run-cycle-light.svg' | prepend:site.baseurl }}" alt="Run cycle explanation"/>
<img class="u-theme-dark u-drop-shadow u-border u-max-width-100" src="{{ '/assets/img/run-cycle-dark.svg' | prepend:site.baseurl }}" alt="Run cycle explanation"/>
</div>



[request]: {% link _docs/request.md %}
[response]: {% link _docs/response.md %}
[capture values]: {% link _docs/capturing-response.md %}
[add asserts to HTTP responses]: {% link _docs/asserting-response.md %}
[`--location`]: {% link _docs/manual.md %}#location
[`--location` option]: {% link _docs/manual.md %}#location
[`--location-trusted`]: {% link _docs/manual.md %}#location-trusted
[`--max-redirs`]: {% link _docs/manual.md %}#max-redirs
[Options]: {% link _docs/manual.md %}#options
Expand All @@ -165,3 +212,5 @@ jsonpath "$.state" == "COMPLETED"
[Asserts]: {% link _docs/response.md %}#asserts
[`--retry`]: {% link _docs/manual.md %}#retry
[`--retry-interval`]: {% link _docs/manual.md %}#retry-interval
[`delay`]: {% link _docs/manual.md %}#retry
[`repeat`]: {% link _docs/manual.md %}#repeat
10 changes: 10 additions & 0 deletions sites/hurl.dev/_docs/filters.md
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,16 @@ jsonpath "$.published" toDate "%Y-%m-%dT%H:%M:%S%.fZ" format "%A" == "Monday"
jsonpath "$.published" toDate "%+" format "%A" == "Monday" # %+ can be used to parse ISO 8601 / RFC 3339
```

### toFloat

Converts to float number.

```hurl
GET https://example.org/foo
HTTP 200
[Asserts]
jsonpath "$.pi" toFloat == 3.14
```

### toInt

Expand Down
Loading

0 comments on commit af7f58e

Please sign in to comment.