mirror of
https://github.com/Orange-OpenSource/hurl.git
synced 2024-11-26 23:23:20 +03:00
Improve assert body test.
This commit is contained in:
parent
ab4dfbc926
commit
91067f9545
@ -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;>
|
||||
|
@ -7,7 +7,7 @@
|
||||
# bGluZTEKbGluZTIKbGluZTMK
|
||||
|
||||
|
||||
GET http://localhost:8000/assert-base64
|
||||
GET http://localhost:8000/error-assert-base64
|
||||
HTTP 200
|
||||
base64,bGluZTEKbGluZTIKbGluZTMK;
|
||||
|
||||
|
@ -1 +0,0 @@
|
||||
curl 'http://localhost:8000/assert-base64'
|
@ -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==;
|
||||
|
@ -1,6 +0,0 @@
|
||||
from app import app
|
||||
|
||||
|
||||
@app.route("/assert-base64")
|
||||
def assert_base64():
|
||||
return "line1\nline2\r\nline3\n"
|
@ -1,3 +0,0 @@
|
||||
#!/bin/bash
|
||||
set -Eeuo pipefail
|
||||
hurl tests_ok/assert_base64.hurl --verbose
|
@ -1,3 +1,3 @@
|
||||
line1
|
||||
line2
|
||||
line2
|
||||
line3
|
4
integration/hurl/tests_ok/assert_body.curl
Normal file
4
integration/hurl/tests_ok/assert_body.curl
Normal 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'
|
35
integration/hurl/tests_ok/assert_body.hurl
Normal file
35
integration/hurl/tests_ok/assert_body.hurl
Normal 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;
|
||||
|
3
integration/hurl/tests_ok/assert_body.out
Normal file
3
integration/hurl/tests_ok/assert_body.out
Normal file
@ -0,0 +1,3 @@
|
||||
line1
|
||||
line2
|
||||
line3
|
@ -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
integration/hurl/tests_ok/assert_body.py
Normal file
11
integration/hurl/tests_ok/assert_body.py
Normal 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"
|
3
integration/hurl/tests_ok/assert_body.sh
Executable file
3
integration/hurl/tests_ok/assert_body.sh
Executable file
@ -0,0 +1,3 @@
|
||||
#!/bin/bash
|
||||
set -Eeuo pipefail
|
||||
hurl --verbose tests_ok/assert_body.hurl
|
@ -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 `
|
||||
|
@ -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 \
|
||||
|
@ -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
|
||||
|
@ -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 `
|
||||
|
@ -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 \
|
||||
|
Loading…
Reference in New Issue
Block a user