Skip to content

Commit

Permalink
Improve assert body test.
Browse files Browse the repository at this point in the history
  • Loading branch information
jcamiel committed Apr 8, 2024
1 parent ab4dfbc commit 91067f9
Show file tree
Hide file tree
Showing 18 changed files with 65 additions and 31 deletions.
2 changes: 1 addition & 1 deletion integration/hurl/tests_failed/assert_base64.err
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
error: Assert body value
--> tests_failed/assert_base64.hurl:12:8
|
| GET http://localhost:8000/assert-base64
| GET http://localhost:8000/error-assert-base64
| ...
12 | base64,bGluZTEKbGluZTIKbGluZTMK;
| ^^^^^^^^^^^^^^^^^^^^^^^^ actual value is <hex, 6c696e65310a6c696e65320d0a6c696e65330a;>
Expand Down
2 changes: 1 addition & 1 deletion integration/hurl/tests_failed/assert_base64.hurl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# bGluZTEKbGluZTIKbGluZTMK


GET http://localhost:8000/assert-base64
GET http://localhost:8000/error-assert-base64
HTTP 200
base64,bGluZTEKbGluZTIKbGluZTMK;

1 change: 0 additions & 1 deletion integration/hurl/tests_ok/assert_base64.curl

This file was deleted.

12 changes: 0 additions & 12 deletions integration/hurl/tests_ok/assert_base64.hurl

This file was deleted.

6 changes: 0 additions & 6 deletions integration/hurl/tests_ok/assert_base64.py

This file was deleted.

3 changes: 0 additions & 3 deletions integration/hurl/tests_ok/assert_base64.sh

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
line1
line2
line2
line3
4 changes: 4 additions & 0 deletions integration/hurl/tests_ok/assert_body.curl
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
curl 'http://localhost:8000/assert-body'
curl 'http://localhost:8000/assert-body'
curl 'http://localhost:8000/assert-body-with-crlf'
curl 'http://localhost:8000/assert-body'
35 changes: 35 additions & 0 deletions integration/hurl/tests_ok/assert_body.hurl
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Implicit body asserts (base64, multiline, file):

GET http://localhost:8000/assert-body
HTTP 200
```
line1
line2
line3
```

GET http://localhost:8000/assert-body
HTTP 200
file,assert_body.bin;


# Test body response with line ending LF and CRLF.
# We receive the text body "line1\nline2\r\nline3\n"
#
# $ printf "line1\nline2\r\nline3\n" | base64
# bGluZTEKbGluZTINCmxpbmUzCg==

GET http://localhost:8000/assert-body-with-crlf
HTTP 200
base64,bGluZTEKbGluZTINCmxpbmUzCg==;


# Explicit body asserts

GET http://localhost:8000/assert-body
HTTP 200
[Asserts]
body == "line1\nline2\nline3\n"
bytes == file,assert_body.bin;
bytes == hex,6c696e65310a6c696e65320a6c696e65330a;

3 changes: 3 additions & 0 deletions integration/hurl/tests_ok/assert_body.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
line1
line2
line3
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Set-StrictMode -Version latest
$ErrorActionPreference = 'Stop'
hurl tests_ok/assert_base64.hurl --verbose
hurl --verbose tests_ok/assert_body.hurl
11 changes: 11 additions & 0 deletions integration/hurl/tests_ok/assert_body.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from app import app


@app.route("/assert-body")
def assert_body():
return "line1\nline2\nline3\n"


@app.route("/assert-body-with-crlf")
def assert_body_with_crlf():
return "line1\nline2\r\nline3\n"
3 changes: 3 additions & 0 deletions integration/hurl/tests_ok/assert_body.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash
set -Eeuo pipefail
hurl --verbose tests_ok/assert_body.hurl
2 changes: 1 addition & 1 deletion integration/hurl/tests_ok/html.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ hurl --test `

hurl --test `
--report-html build\tmp\ `
tests_ok\assert_base64.hurl `
tests_ok\assert_body.hurl `
tests_ok\assert_header.hurl `
tests_ok\assert_json.hurl `
tests_ok\assert_match.hurl `
Expand Down
2 changes: 1 addition & 1 deletion integration/hurl/tests_ok/html.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ hurl --test \

hurl --test \
--report-html build/a/b/c/ \
tests_ok/assert_base64.hurl \
tests_ok/assert_body.hurl \
tests_ok/assert_header.hurl \
tests_ok/assert_json.hurl \
tests_ok/assert_match.hurl \
Expand Down
2 changes: 1 addition & 1 deletion integration/hurl/tests_ok/parallel_all.out
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
TAP version 13
1..92
ok 1 - tests_ok/assert_base64.hurl
ok 1 - tests_ok/assert_body.hurl
ok 2 - tests_ok/assert_header.hurl
ok 3 - tests_ok/assert_json.hurl
ok 4 - tests_ok/assert_match.hurl
Expand Down
2 changes: 1 addition & 1 deletion integration/hurl/tests_ok/parallel_all.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ $ErrorActionPreference = 'Continue'

hurl --parallel --test `
--report-tap build/parallel-all.txt `
tests_ok/assert_base64.hurl `
tests_ok/assert_body.hurl `
tests_ok/assert_header.hurl `
tests_ok/assert_json.hurl `
tests_ok/assert_match.hurl `
Expand Down
2 changes: 1 addition & 1 deletion integration/hurl/tests_ok/parallel_all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ set +euo pipefail

hurl --parallel --test \
--report-tap build/parallel-all.txt \
tests_ok/assert_base64.hurl \
tests_ok/assert_body.hurl \
tests_ok/assert_header.hurl \
tests_ok/assert_json.hurl \
tests_ok/assert_match.hurl \
Expand Down

0 comments on commit 91067f9

Please sign in to comment.