From b0ba08ec21e264709e0d3c94d7523efd04d35a63 Mon Sep 17 00:00:00 2001 From: jcamiel Date: Mon, 14 Sep 2020 15:19:26 +0200 Subject: [PATCH] Add optional options in integration tests. --- integration/run.sh | 12 ++++++++++-- integration/tests/follow_redirect.exit | 1 + integration/tests/follow_redirect.hurl | 3 +++ integration/tests/follow_redirect.options | 1 + integration/tests/follow_redirect.out | 1 + integration/tests/follow_redirect.py | 14 ++++++++++++++ 6 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 integration/tests/follow_redirect.exit create mode 100644 integration/tests/follow_redirect.hurl create mode 100644 integration/tests/follow_redirect.options create mode 100644 integration/tests/follow_redirect.out create mode 100644 integration/tests/follow_redirect.py diff --git a/integration/run.sh b/integration/run.sh index b92c7d101..8c9224a46 100755 --- a/integration/run.sh +++ b/integration/run.sh @@ -3,9 +3,17 @@ set -u set -e for hurl_file in "$@"; do - echo "$hurl_file"; set +e - hurl "$hurl_file" --color 2>/tmp/test.stderr >/tmp/test.stdout + + options=("--color") + if test -f "${hurl_file%.*}.options"; then + options+=("$(cat "${hurl_file%.*}.options")") + fi + + cmd="hurl $hurl_file ${options[@]}" + echo "$cmd" + + $cmd 2>/tmp/test.stderr >/tmp/test.stdout EXITCODE_ACTUAL=$? set -e diff --git a/integration/tests/follow_redirect.exit b/integration/tests/follow_redirect.exit new file mode 100644 index 000000000..c22708346 --- /dev/null +++ b/integration/tests/follow_redirect.exit @@ -0,0 +1 @@ +0 \ No newline at end of file diff --git a/integration/tests/follow_redirect.hurl b/integration/tests/follow_redirect.hurl new file mode 100644 index 000000000..115e1e5a2 --- /dev/null +++ b/integration/tests/follow_redirect.hurl @@ -0,0 +1,3 @@ +GET http://localhost:8000/follow-redirect +HTTP/1.0 200 +```Followed redirect!``` \ No newline at end of file diff --git a/integration/tests/follow_redirect.options b/integration/tests/follow_redirect.options new file mode 100644 index 000000000..32dcfc9f3 --- /dev/null +++ b/integration/tests/follow_redirect.options @@ -0,0 +1 @@ +-L --verbose \ No newline at end of file diff --git a/integration/tests/follow_redirect.out b/integration/tests/follow_redirect.out new file mode 100644 index 000000000..91962274b --- /dev/null +++ b/integration/tests/follow_redirect.out @@ -0,0 +1 @@ +Followed redirect! diff --git a/integration/tests/follow_redirect.py b/integration/tests/follow_redirect.py new file mode 100644 index 000000000..bcf3b2829 --- /dev/null +++ b/integration/tests/follow_redirect.py @@ -0,0 +1,14 @@ +from tests import app +from flask import redirect + +@app.route('/follow-redirect') +def follow_redirect(): + return redirect('http://localhost:8000/following-redirect') + +@app.route('/following-redirect') +def following_redirect(): + return redirect('http://localhost:8000/followed-redirect') + +@app.route('/followed-redirect') +def followed_redirect(): + return 'Followed redirect!'