From 2551b890801d7cd68712aed375ae29c3982863a2 Mon Sep 17 00:00:00 2001 From: Fabrice Reix Date: Thu, 4 Jul 2024 13:22:50 +0200 Subject: [PATCH] Add test integ for diff --- integration/hurl/tests_failed/diff.err | 89 +++++++++ integration/hurl/tests_failed/diff.exit | 1 + integration/hurl/tests_failed/diff.hurl | 235 ++++++++++++++++++++++++ integration/hurl/tests_failed/diff.ps1 | 3 + integration/hurl/tests_failed/diff.py | 232 +++++++++++++++++++++++ integration/hurl/tests_failed/diff.sh | 3 + 6 files changed, 563 insertions(+) create mode 100644 integration/hurl/tests_failed/diff.err create mode 100644 integration/hurl/tests_failed/diff.exit create mode 100644 integration/hurl/tests_failed/diff.hurl create mode 100755 integration/hurl/tests_failed/diff.ps1 create mode 100644 integration/hurl/tests_failed/diff.py create mode 100755 integration/hurl/tests_failed/diff.sh diff --git a/integration/hurl/tests_failed/diff.err b/integration/hurl/tests_failed/diff.err new file mode 100644 index 000000000..fae44cfd7 --- /dev/null +++ b/integration/hurl/tests_failed/diff.err @@ -0,0 +1,89 @@ +error: Assert body value + --> tests_failed/diff.hurl:6:1 + | + | GET http://localhost:8000/diff/change/line1 + | ... + 6 |-{ + |+[ + | "first_name": "John", + | "last_name": "Smith", + | "is_alive": true, + | + +error: Assert body value + --> tests_failed/diff.hurl:40:1 + | + | GET http://localhost:8000/diff/change/line2 + | ... + | { + 40 |- "first_name": "John", + |+ "first_name": "Bob", + | "last_name": "Smith", + | "is_alive": true, + | "age": 27, + | + +error: Assert status code + --> tests_failed/diff.hurl:70:6 + | + | GET http://localhost:8000/diff/change/line3 + 70 | HTTP 200 + | ^^^ actual value is <404> + | + +error: Assert body value + --> tests_failed/diff.hurl:108:1 + | + | GET http://localhost:8000/diff/change/line4 + | ... + | { + | "first_name": "John", + | "last_name": "Smith", +108 |- "is_alive": true, + |+ "is_alive": false, + | "age": 27, + | "address": { + | "street_address": "21 2nd Street", + | + +error: Assert body value + --> tests_failed/diff.hurl:142:1 + | + | GET http://localhost:8000/diff/change/line5 + | ... + | "first_name": "John", + | "last_name": "Smith", + | "is_alive": true, +142 |- "age": 27, + |+ "age": 28, + | "address": { + | "street_address": "21 2nd Street", + | "city": "New York", + | + +error: Assert body value + --> tests_failed/diff.hurl:174:1 + | + | GET http://localhost:8000/diff/delete/line3 + | ... + | { + | "first_name": "John", +174 |- "last_name": "Smith", + | "is_alive": true, + | "age": 27, + | "address": { + | + +error: Assert body value + --> tests_failed/diff.hurl:208:1 + | + | GET http://localhost:8000/diff/add/line3 + | ... + | { +208 | "first_name": "John", + |+ "middle_name": "Bob", + | "last_name": "Smith", + | "is_alive": true, + | "age": 27, + | + diff --git a/integration/hurl/tests_failed/diff.exit b/integration/hurl/tests_failed/diff.exit new file mode 100644 index 000000000..b8626c4cf --- /dev/null +++ b/integration/hurl/tests_failed/diff.exit @@ -0,0 +1 @@ +4 diff --git a/integration/hurl/tests_failed/diff.hurl b/integration/hurl/tests_failed/diff.hurl new file mode 100644 index 000000000..235de5a28 --- /dev/null +++ b/integration/hurl/tests_failed/diff.hurl @@ -0,0 +1,235 @@ +# The expected JSON will be exactly the same for all the entries + +GET http://localhost:8000/diff/change/line1 +HTTP 200 +``` +{ + "first_name": "John", + "last_name": "Smith", + "is_alive": true, + "age": 27, + "address": { + "street_address": "21 2nd Street", + "city": "New York", + "state": "NY", + "postal_code": "10021-3100" + }, + "phone_numbers": [ + { + "type": "home", + "number": "212 555-1234" + }, + { + "type": "office", + "number": "646 555-4567" + } + ], + "children": [ + "Catherine", + "Thomas", + "Trevor" + ], + "spouse": null +} +``` + +GET http://localhost:8000/diff/change/line2 +HTTP 200 +``` +{ + "first_name": "John", + "last_name": "Smith", + "is_alive": true, + "age": 27, + "address": { + "street_address": "21 2nd Street", + "city": "New York", + "state": "NY", + "postal_code": "10021-3100" + }, + "phone_numbers": [ + { + "type": "home", + "number": "212 555-1234" + }, + { + "type": "office", + "number": "646 555-4567" + } + ], + "children": [ + "Catherine", + "Thomas", + "Trevor" + ], + "spouse": null +} +``` + +GET http://localhost:8000/diff/change/line3 +HTTP 200 +``` +{ + "first_name": "John", + "last_name": "Smith", + "is_alive": true, + "age": 27, + "address": { + "street_address": "21 2nd Street", + "city": "New York", + "state": "NY", + "postal_code": "10021-3100" + }, + "phone_numbers": [ + { + "type": "home", + "number": "212 555-1234" + }, + { + "type": "office", + "number": "646 555-4567" + } + ], + "children": [ + "Catherine", + "Thomas", + "Trevor" + ], + "spouse": null +} +``` + +GET http://localhost:8000/diff/change/line4 +HTTP 200 +``` +{ + "first_name": "John", + "last_name": "Smith", + "is_alive": true, + "age": 27, + "address": { + "street_address": "21 2nd Street", + "city": "New York", + "state": "NY", + "postal_code": "10021-3100" + }, + "phone_numbers": [ + { + "type": "home", + "number": "212 555-1234" + }, + { + "type": "office", + "number": "646 555-4567" + } + ], + "children": [ + "Catherine", + "Thomas", + "Trevor" + ], + "spouse": null +} +``` + +GET http://localhost:8000/diff/change/line5 +HTTP 200 +``` +{ + "first_name": "John", + "last_name": "Smith", + "is_alive": true, + "age": 27, + "address": { + "street_address": "21 2nd Street", + "city": "New York", + "state": "NY", + "postal_code": "10021-3100" + }, + "phone_numbers": [ + { + "type": "home", + "number": "212 555-1234" + }, + { + "type": "office", + "number": "646 555-4567" + } + ], + "children": [ + "Catherine", + "Thomas", + "Trevor" + ], + "spouse": null +} +``` + + +GET http://localhost:8000/diff/delete/line3 +HTTP 200 +``` +{ + "first_name": "John", + "last_name": "Smith", + "is_alive": true, + "age": 27, + "address": { + "street_address": "21 2nd Street", + "city": "New York", + "state": "NY", + "postal_code": "10021-3100" + }, + "phone_numbers": [ + { + "type": "home", + "number": "212 555-1234" + }, + { + "type": "office", + "number": "646 555-4567" + } + ], + "children": [ + "Catherine", + "Thomas", + "Trevor" + ], + "spouse": null +} +``` + + + +GET http://localhost:8000/diff/add/line3 +HTTP 200 +``` +{ + "first_name": "John", + "last_name": "Smith", + "is_alive": true, + "age": 27, + "address": { + "street_address": "21 2nd Street", + "city": "New York", + "state": "NY", + "postal_code": "10021-3100" + }, + "phone_numbers": [ + { + "type": "home", + "number": "212 555-1234" + }, + { + "type": "office", + "number": "646 555-4567" + } + ], + "children": [ + "Catherine", + "Thomas", + "Trevor" + ], + "spouse": null +} +``` diff --git a/integration/hurl/tests_failed/diff.ps1 b/integration/hurl/tests_failed/diff.ps1 new file mode 100755 index 000000000..f93ba42f3 --- /dev/null +++ b/integration/hurl/tests_failed/diff.ps1 @@ -0,0 +1,3 @@ +Set-StrictMode -Version latest +$ErrorActionPreference = 'Stop' +hurl --continue-on-error --no-color tests_failed/diff.hurl diff --git a/integration/hurl/tests_failed/diff.py b/integration/hurl/tests_failed/diff.py new file mode 100644 index 000000000..7a5427c92 --- /dev/null +++ b/integration/hurl/tests_failed/diff.py @@ -0,0 +1,232 @@ +from app import app + + +@app.route("/diff/change/line1") +def error_diff_change_line1(): + return """[ + "first_name": "John", + "last_name": "Smith", + "is_alive": true, + "age": 27, + "address": { + "street_address": "21 2nd Street", + "city": "New York", + "state": "NY", + "postal_code": "10021-3100" + }, + "phone_numbers": [ + { + "type": "home", + "number": "212 555-1234" + }, + { + "type": "office", + "number": "646 555-4567" + } + ], + "children": [ + "Catherine", + "Thomas", + "Trevor" + ], + "spouse": null +} +""" + + +@app.route("/diff/change/line2") +def error_diff_change_line2(): + return """{ + "first_name": "Bob", + "last_name": "Smith", + "is_alive": true, + "age": 27, + "address": { + "street_address": "21 2nd Street", + "city": "New York", + "state": "NY", + "postal_code": "10021-3100" + }, + "phone_numbers": [ + { + "type": "home", + "number": "212 555-1234" + }, + { + "type": "office", + "number": "646 555-4567" + } + ], + "children": [ + "Catherine", + "Thomas", + "Trevor" + ], + "spouse": null +} +""" + + +@app.route("/diff/change/line1") +def error_diff_change_line3(): + return """{ + "first_name": "John", + "last_name": "Smiths", + "is_alive": true, + "age": 27, + "address": { + "street_address": "21 2nd Street", + "city": "New York", + "state": "NY", + "postal_code": "10021-3100" + }, + "phone_numbers": [ + { + "type": "home", + "number": "212 555-1234" + }, + { + "type": "office", + "number": "646 555-4567" + } + ], + "children": [ + "Catherine", + "Thomas", + "Trevor" + ], + "spouse": null +} +""" + + +@app.route("/diff/change/line4") +def error_diff_change_line4(): + return """{ + "first_name": "John", + "last_name": "Smith", + "is_alive": false, + "age": 27, + "address": { + "street_address": "21 2nd Street", + "city": "New York", + "state": "NY", + "postal_code": "10021-3100" + }, + "phone_numbers": [ + { + "type": "home", + "number": "212 555-1234" + }, + { + "type": "office", + "number": "646 555-4567" + } + ], + "children": [ + "Catherine", + "Thomas", + "Trevor" + ], + "spouse": null +} +""" + + +@app.route("/diff/change/line5") +def error_diff_change_line5(): + return """{ + "first_name": "John", + "last_name": "Smith", + "is_alive": true, + "age": 28, + "address": { + "street_address": "21 2nd Street", + "city": "New York", + "state": "NY", + "postal_code": "10021-3100" + }, + "phone_numbers": [ + { + "type": "home", + "number": "212 555-1234" + }, + { + "type": "office", + "number": "646 555-4567" + } + ], + "children": [ + "Catherine", + "Thomas", + "Trevor" + ], + "spouse": null +} +""" + + +@app.route("/diff/delete/line3") +def error_diff_delete_line3(): + return """{ + "first_name": "John", + "is_alive": true, + "age": 27, + "address": { + "street_address": "21 2nd Street", + "city": "New York", + "state": "NY", + "postal_code": "10021-3100" + }, + "phone_numbers": [ + { + "type": "home", + "number": "212 555-1234" + }, + { + "type": "office", + "number": "646 555-4567" + } + ], + "children": [ + "Catherine", + "Thomas", + "Trevor" + ], + "spouse": null +} +""" + + +@app.route("/diff/add/line3") +def error_diff_add_line3(): + return """{ + "first_name": "John", + "middle_name": "Bob", + "last_name": "Smith", + "is_alive": true, + "age": 27, + "address": { + "street_address": "21 2nd Street", + "city": "New York", + "state": "NY", + "postal_code": "10021-3100" + }, + "phone_numbers": [ + { + "type": "home", + "number": "212 555-1234" + }, + { + "type": "office", + "number": "646 555-4567" + } + ], + "children": [ + "Catherine", + "Thomas", + "Trevor" + ], + "spouse": null +} +""" diff --git a/integration/hurl/tests_failed/diff.sh b/integration/hurl/tests_failed/diff.sh new file mode 100755 index 000000000..0cd88defa --- /dev/null +++ b/integration/hurl/tests_failed/diff.sh @@ -0,0 +1,3 @@ +#!/bin/bash +set -Eeuo pipefail +hurl --continue-on-error --no-color tests_failed/diff.hurl