Add test integ for diff

This commit is contained in:
Fabrice Reix 2024-07-04 13:22:50 +02:00
parent 6913ce92e2
commit 2551b89080
No known key found for this signature in database
GPG Key ID: BF5213154B2E7155
6 changed files with 563 additions and 0 deletions

View File

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

View File

@ -0,0 +1 @@
4

View File

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

View File

@ -0,0 +1,3 @@
Set-StrictMode -Version latest
$ErrorActionPreference = 'Stop'
hurl --continue-on-error --no-color tests_failed/diff.hurl

View File

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

View File

@ -0,0 +1,3 @@
#!/bin/bash
set -Eeuo pipefail
hurl --continue-on-error --no-color tests_failed/diff.hurl