Improve assert body test.

This commit is contained in:
jcamiel 2024-04-04 18:15:45 +02:00
parent ab4dfbc926
commit 91067f9545
No known key found for this signature in database
GPG Key ID: 07FF11CFD55356CC
18 changed files with 65 additions and 31 deletions

View File

@ -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;>

View File

@ -7,7 +7,7 @@
# bGluZTEKbGluZTIKbGluZTMK
GET http://localhost:8000/assert-base64
GET http://localhost:8000/error-assert-base64
HTTP 200
base64,bGluZTEKbGluZTIKbGluZTMK;

View File

@ -1 +0,0 @@
curl 'http://localhost:8000/assert-base64'

View File

@ -1,12 +0,0 @@
# 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-base64
HTTP 200
base64,bGluZTEKbGluZTINCmxpbmUzCg==;

View File

@ -1,6 +0,0 @@
from app import app
@app.route("/assert-base64")
def assert_base64():
return "line1\nline2\r\nline3\n"

View File

@ -1,3 +0,0 @@
#!/bin/bash
set -Eeuo pipefail
hurl tests_ok/assert_base64.hurl --verbose

View File

@ -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'

View File

@ -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;

View File

@ -0,0 +1,3 @@
line1
line2
line3

View File

@ -1,3 +1,3 @@
Set-StrictMode -Version latest
$ErrorActionPreference = 'Stop'
hurl tests_ok/assert_base64.hurl --verbose
hurl --verbose tests_ok/assert_body.hurl

View File

@ -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"

View File

@ -0,0 +1,3 @@
#!/bin/bash
set -Eeuo pipefail
hurl --verbose tests_ok/assert_body.hurl

View File

@ -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 `

View File

@ -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 \

View File

@ -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

View File

@ -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 `

View File

@ -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 \