Skip to content

Commit

Permalink
Test pretty-printed JSON output
Browse files Browse the repository at this point in the history
  • Loading branch information
fabricereix committed Apr 5, 2024
1 parent 8dbd6f6 commit 7f31d87
Show file tree
Hide file tree
Showing 12 changed files with 154 additions and 11 deletions.
2 changes: 1 addition & 1 deletion bin/install_prerequisites_alpine.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ set -Eeuo pipefail

echo "----- install prerequisite packages -----"
apk update --quiet
apk add --quiet sudo bash sudo netcat-openbsd curl curl-dev build-base libidn2 libffi-dev libxml2-dev libxml2-utils openssl-dev python3 python3-dev py3-pip cargo squid
apk add --quiet sudo bash sudo netcat-openbsd curl curl-dev build-base libidn2 libffi-dev libxml2-dev libxml2-utils openssl-dev python3 python3-dev py3-pip cargo squid jq
sudo squid -k shutdown || true
sudo rm -v /dev/shm/squid*.shm >/dev/null 2>&1 || true
2 changes: 1 addition & 1 deletion bin/install_prerequisites_archlinux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
set -Eeuo pipefail

echo "----- install prerequisite packages -----"
pacman -Syu --noconfirm bash sudo icu base-devel libxml2 python3 python3-venv glibc openbsd-netcat squid
pacman -Syu --noconfirm bash sudo icu base-devel libxml2 python3 python3-venv glibc openbsd-netcat squid jq
sudo squid -k shutdown || true
sudo rm -v /dev/shm/squid*.shm >/dev/null 2>&1 || true
2 changes: 1 addition & 1 deletion bin/install_prerequisites_docker_archlinux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
set -Eeuo pipefail

echo "----- install prerequisite packages -----"
pacman -Sy --noconfirm bash sudo python3 python-pip icu base-devel libxml2 glibc openbsd-netcat squid
pacman -Sy --noconfirm bash sudo python3 python-pip icu base-devel libxml2 glibc openbsd-netcat squid jq
sudo squid -k shutdown || true
sudo rm -v /dev/shm/squid*.shm >/dev/null 2>&1 || true

2 changes: 1 addition & 1 deletion bin/install_prerequisites_docker_fedora.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
set -Eeuo pipefail

echo "----- install prerequisite packages -----"
yum install -y sudo which python3 python3-pip procps gcc libxml2-devel openssl-devel libcurl-devel nc squid
yum install -y sudo which python3 python3-pip procps gcc libxml2-devel openssl-devel libcurl-devel nc squid jq
sudo squid -k shutdown || true
sudo rm -v /dev/shm/squid*.shm >/dev/null 2>&1 || true

3 changes: 2 additions & 1 deletion bin/install_prerequisites_docker_ubuntu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ apt-get -y install \
python3-pip \
python3-venv \
netcat-openbsd \
squid
squid \
jq
sudo service squid stop
sudo squid -k shutdown || true
sudo rm -v /dev/shm/squid*.shm >/dev/null 2>&1 || true
Expand Down
2 changes: 1 addition & 1 deletion bin/install_prerequisites_fedora.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
set -Eeuo pipefail

echo "----- install prerequisite packages -----"
yum install -y bash sudo procps gcc libxml2-devel openssl-devel libcurl-devel python3-devel python3-pip nc squid
yum install -y bash sudo procps gcc libxml2-devel openssl-devel libcurl-devel python3-devel python3-pip nc squid jq
sudo squid -k shutdown || true
sudo rm -v /dev/shm/squid*.shm >/dev/null 2>&1 || true

2 changes: 1 addition & 1 deletion bin/install_prerequisites_macos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export CURL_PATH
echo "CURL_PATH=$CURL_PATH"
PATH="$CURL_PATH:$PATH"
export PATH
brew install bash pkg-config squid
brew install bash pkg-config squid jq
sudo squid -k shutdown || true
sudo rm -v /dev/shm/squid*.shm >/dev/null 2>&1 || true

2 changes: 1 addition & 1 deletion bin/install_prerequisites_ubuntu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ set -Eeuo pipefail

echo "----- install prerequisite packages -----"
sudo apt-get update
sudo apt-get -y install bash libcurl4-openssl-dev libxml2-utils netcat-openbsd python3 python3-pip python3-venv net-tools squid
sudo apt-get -y install bash libcurl4-openssl-dev libxml2-utils netcat-openbsd python3 python3-pip python3-venv net-tools squid jq
sudo service squid stop || true
sudo squid -k shutdown || true
sudo rm -v /dev/shm/squid*.shm >/dev/null 2>&1 || true
Expand Down
4 changes: 4 additions & 0 deletions bin/install_prerequisites_windows.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,7 @@ sc queryex squidsrv | tee -Append -filepath integration\build\proxy.log
echo "==== Squid process status"
Get-Process | Where {$_.Name -eq "Squid"} | tee -Append -filepath integration\build\proxy.log

# install jq
echo "==== install jq"
choco install --confirm jq
if ($LASTEXITCODE) { Throw }
130 changes: 129 additions & 1 deletion integration/hurl/tests_failed/assert_value_error.out.pattern
Original file line number Diff line number Diff line change
@@ -1 +1,129 @@
{"cookies":[],"entries":[{"asserts":[{"line":2,"success":true},{"line":2,"success":true},{"line":4,"message":"Assert failure\n --> tests_failed/assert_value_error.hurl:4:0\n |\n | GET http://localhost:8000/error-assert-value\n | ...\n 4 | header \"content-type\" == \"XXX\"\n | actual: string <text/html; charset=utf-8>\n | expected: string <XXX>\n |","success":false},{"line":5,"message":"Assert failure\n --> tests_failed/assert_value_error.hurl:5:0\n |\n | GET http://localhost:8000/error-assert-value\n | ...\n 5 | header \"content-type\" != \"text/html; charset=utf-8\"\n | actual: string <text/html; charset=utf-8>\n | expected: string <text/html; charset=utf-8>\n |","success":false},{"line":6,"message":"Assert failure\n --> tests_failed/assert_value_error.hurl:6:0\n |\n | GET http://localhost:8000/error-assert-value\n | ...\n 6 | jsonpath \"$.id\" == \"000001\"\n | actual: none\n | expected: string <000001>\n |","success":false},{"line":7,"message":"Assert failure\n --> tests_failed/assert_value_error.hurl:7:0\n |\n | GET http://localhost:8000/error-assert-value\n | ...\n 7 | jsonpath \"$.values\" includes 100\n | actual: [int <1>, int <2>, int <3>]\n | expected: includes int <100>\n |","success":false},{"line":8,"message":"Assert failure\n --> tests_failed/assert_value_error.hurl:8:0\n |\n | GET http://localhost:8000/error-assert-value\n | ...\n 8 | jsonpath \"$.values\" not contains \"Hello\"\n | actual: [int <1>, int <2>, int <3>]\n | expected: not contains string <Hello>\n | >>> types between actual and expected are not consistent\n |","success":false},{"line":9,"message":"Assert failure\n --> tests_failed/assert_value_error.hurl:9:0\n |\n | GET http://localhost:8000/error-assert-value\n | ...\n 9 | jsonpath \"$.count\" > 5\n | actual: int <2>\n | expected: greater than int <5>\n |","success":false},{"line":10,"message":"Assert failure\n --> tests_failed/assert_value_error.hurl:10:0\n |\n | GET http://localhost:8000/error-assert-value\n | ...\n10 | jsonpath \"$.count\" isFloat\n | actual: int <2>\n | expected: float\n |","success":false},{"line":11,"message":"Assert failure\n --> tests_failed/assert_value_error.hurl:11:0\n |\n | GET http://localhost:8000/error-assert-value\n | ...\n11 | bytes contains hex,00;\n | actual: byte array <7b202276616c756573223a205b312c322c335d2c2022636f756e74223a20327d>\n | expected: contains byte array <00>\n |","success":false}],"calls":[{"request":{"cookies":[],"headers":[{"name":"Host","value":"localhost:8000"},{"name":"Accept","value":"*/*"},{"name":"User-Agent","value":"hurl/~~~"}],"method":"GET","queryString":[],"url":"http://localhost:8000/error-assert-value"},"response":{"cookies":[],"headers":[{"name":"Server","value":"Werkzeug/~~~ Python/~~~"},{"name":"Date","value":"~~~"},{"name":"Content-Type","value":"text/html; charset=utf-8"},{"name":"Content-Length","value":"32"},{"name":"Server","value":"Flask Server"},{"name":"Connection","value":"close"}],"httpVersion":"HTTP/1.1","status":200},"timings":{"app_connect":~~~,"begin_call":"~~~","connect":~~~,"end_call":"~~~","name_lookup":~~~,"pre_transfer":~~~,"start_transfer":~~~,"total":~~~}}],"captures":[],"index":1,"line":1,"time":~~~}],"filename":"tests_failed/assert_value_error.hurl","success":false,"time":~~~}
{
"cookies": [],
"entries": [
{
"asserts": [
{
"line": 2,
"success": true
},
{
"line": 2,
"success": true
},
{
"line": 4,
"message": "Assert failure\n --> tests_failed/assert_value_error.hurl:4:0\n |\n | GET http://localhost:8000/error-assert-value\n | ...\n 4 | header \"content-type\" == \"XXX\"\n | actual: string <text/html; charset=utf-8>\n | expected: string <XXX>\n |",
"success": false
},
{
"line": 5,
"message": "Assert failure\n --> tests_failed/assert_value_error.hurl:5:0\n |\n | GET http://localhost:8000/error-assert-value\n | ...\n 5 | header \"content-type\" != \"text/html; charset=utf-8\"\n | actual: string <text/html; charset=utf-8>\n | expected: string <text/html; charset=utf-8>\n |",
"success": false
},
{
"line": 6,
"message": "Assert failure\n --> tests_failed/assert_value_error.hurl:6:0\n |\n | GET http://localhost:8000/error-assert-value\n | ...\n 6 | jsonpath \"$.id\" == \"000001\"\n | actual: none\n | expected: string <000001>\n |",
"success": false
},
{
"line": 7,
"message": "Assert failure\n --> tests_failed/assert_value_error.hurl:7:0\n |\n | GET http://localhost:8000/error-assert-value\n | ...\n 7 | jsonpath \"$.values\" includes 100\n | actual: [int <1>, int <2>, int <3>]\n | expected: includes int <100>\n |",
"success": false
},
{
"line": 8,
"message": "Assert failure\n --> tests_failed/assert_value_error.hurl:8:0\n |\n | GET http://localhost:8000/error-assert-value\n | ...\n 8 | jsonpath \"$.values\" not contains \"Hello\"\n | actual: [int <1>, int <2>, int <3>]\n | expected: not contains string <Hello>\n | >>> types between actual and expected are not consistent\n |",
"success": false
},
{
"line": 9,
"message": "Assert failure\n --> tests_failed/assert_value_error.hurl:9:0\n |\n | GET http://localhost:8000/error-assert-value\n | ...\n 9 | jsonpath \"$.count\" > 5\n | actual: int <2>\n | expected: greater than int <5>\n |",
"success": false
},
{
"line": 10,
"message": "Assert failure\n --> tests_failed/assert_value_error.hurl:10:0\n |\n | GET http://localhost:8000/error-assert-value\n | ...\n10 | jsonpath \"$.count\" isFloat\n | actual: int <2>\n | expected: float\n |",
"success": false
},
{
"line": 11,
"message": "Assert failure\n --> tests_failed/assert_value_error.hurl:11:0\n |\n | GET http://localhost:8000/error-assert-value\n | ...\n11 | bytes contains hex,00;\n | actual: byte array <7b202276616c756573223a205b312c322c335d2c2022636f756e74223a20327d>\n | expected: contains byte array <00>\n |",
"success": false
}
],
"calls": [
{
"request": {
"cookies": [],
"headers": [
{
"name": "Host",
"value": "localhost:8000"
},
{
"name": "Accept",
"value": "*/*"
},
{
"name": "User-Agent",
"value": "hurl/~~~"
}
],
"method": "GET",
"queryString": [],
"url": "http://localhost:8000/error-assert-value"
},
"response": {
"cookies": [],
"headers": [
{
"name": "Server",
"value": "Werkzeug/~~~"
},
{
"name": "Date",
"value": "~~~"
},
{
"name": "Content-Type",
"value": "text/html; charset=utf-8"
},
{
"name": "Content-Length",
"value": "32"
},
{
"name": "Server",
"value": "Flask Server"
},
{
"name": "Connection",
"value": "close"
}
],
"httpVersion": "HTTP/1.1",
"status": 200
},
"timings": {
"app_connect": ~~~,
"begin_call": "~~~",
"connect": ~~~,
"end_call": "~~~",
"name_lookup": ~~~,
"pre_transfer": ~~~,
"start_transfer": ~~~,
"total": ~~~
}
}
],
"captures": [],
"index": 1,
"line": 1,
"time": ~~~
}
],
"filename": "tests_failed/assert_value_error.hurl",
"success": false,
"time": ~~~
}
6 changes: 5 additions & 1 deletion integration/hurl/tests_failed/assert_value_error.ps1
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
Set-StrictMode -Version latest
$ErrorActionPreference = 'Stop'
hurl --json tests_failed/assert_value_error.hurl

$out=hurl --json tests_failed/assert_value_error.hurl
$exit_code="$lastexitcode"
echo "$out" | jq
exit "$exit_code"
8 changes: 7 additions & 1 deletion integration/hurl/tests_failed/assert_value_error.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
#!/bin/bash
set -Eeuo pipefail
hurl --json tests_failed/assert_value_error.hurl

set +e
out=$(hurl --json tests_failed/assert_value_error.hurl)
exit_code="$?"
echo "$out" | jq
exit "$exit_code"

0 comments on commit 7f31d87

Please sign in to comment.