Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test integ #1934

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion integration/tests_ok/html.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ hurl --test `
tests_ok\post_large.hurl `
tests_ok\post_multilines.hurl `
tests_ok\post_xml.hurl `
tests_ok\predicates-string.hurl `
tests_ok\predicates_string.hurl `
tests_ok\proxy_option.hurl `
tests_ok\put.hurl `
tests_ok\querystring_params.hurl `
Expand Down
2 changes: 1 addition & 1 deletion integration/tests_ok/html.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ hurl --test \
tests_ok/post_large.hurl \
tests_ok/post_multilines.hurl \
tests_ok/post_xml.hurl \
tests_ok/predicates-string.hurl \
tests_ok/predicates_string.hurl \
tests_ok/proxy_option.hurl \
tests_ok/put.hurl \
tests_ok/querystring_params.hurl \
Expand Down
65 changes: 65 additions & 0 deletions integration/tests_ok/jsonpath_store.hurl
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Example from https://goessner.net/articles/JsonPath/
GET http://localhost:8000/json/store
HTTP 200
[Asserts]
jsonpath "$.store.book[*].author" count == 4 # the authors of all books in the store
jsonpath "$.store.book[*].author" nth 0 == "Nigel Rees"
jsonpath "$.store.book[*].author" nth 1 == "Evelyn Waugh"
jsonpath "$.store.book[*].author" nth 2 == "Herman Melville"
jsonpath "$.store.book[*].author" nth 3 == "J. R. R. Tolkien"
jsonpath "$..author" count == 4 # all authors
jsonpath "$..author" nth 0 == "Nigel Rees"
jsonpath "$..author" nth 1 == "Evelyn Waugh"
jsonpath "$..author" nth 2 == "Herman Melville"
jsonpath "$..author" nth 3 == "J. R. R. Tolkien"
jsonpath "$.store.*" count == 2 # all things in store, which are some books and a red bicycle.
jsonpath "$.store..price" count == 5 # the price of everything in the store.
jsonpath "$..book[2].title" nth 0 == "Moby Dick" # the third book
#jsonpath "$..book[(@.length-1)]" nth 0 == "fiction" # not supported yet
jsonpath "$..book[-1:].title" nth 0 == "The Lord of the Rings" # the last book in order.
jsonpath "$..book[0,1]" count == 2 # the first two books
jsonpath "$..book[0,1].title" nth 0 == "Sayings of the Century"
jsonpath "$..book[0,1].title" nth 1 == "Sword of Honour"
jsonpath "$..book[:2]" count == 2
jsonpath "$..book[:2].title" nth 0 == "Sayings of the Century"
jsonpath "$..book[:2].title" nth 1 == "Sword of Honour"
jsonpath "$..book[?(@.isbn)]" count == 2 # filter all books with isbn number
jsonpath "$..book[?(@.isbn)].title" nth 0 == "Moby Dick"
jsonpath "$..book[?(@.isbn)].title" nth 1 == "The Lord of the Rings"
jsonpath "$..book[?(@.price<10)]" count == 2 # filter all books cheapier than 10
jsonpath "$..book[?(@.price<10)].title" nth 0 == "Sayings of the Century"
jsonpath "$..book[?(@.price<10)].title" nth 1 == "Moby Dick"
jsonpath "$..*" count == 27 # all Elements in XML document. All members of JSON structure.

{
"store": {
"book": [
{ "category": "reference",
"author": "Nigel Rees",
"title": "Sayings of the Century",
"price": 8.95
},
{ "category": "fiction",
"author": "Evelyn Waugh",
"title": "Sword of Honour",
"price": 12.99
},
{ "category": "fiction",
"author": "Herman Melville",
"title": "Moby Dick",
"isbn": "0-553-21311-3",
"price": 8.99
},
{ "category": "fiction",
"author": "J. R. R. Tolkien",
"title": "The Lord of the Rings",
"isbn": "0-395-19395-8",
"price": 22.99
}
],
"bicycle": {
"color": "red",
"price": 19.95
}
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Set-StrictMode -Version latest
$ErrorActionPreference = 'Stop'
hurl tests_ok/predicates-string.hurl --verbose
hurl tests_ok/jsonpath_store.hurl --verbose
41 changes: 41 additions & 0 deletions integration/tests_ok/jsonpath_store.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
from app import app
from flask import Response


@app.route("/json/store")
def json_store():
return Response(
"""{
"store": {
"book": [
{ "category": "reference",
"author": "Nigel Rees",
"title": "Sayings of the Century",
"price": 8.95
},
{ "category": "fiction",
"author": "Evelyn Waugh",
"title": "Sword of Honour",
"price": 12.99
},
{ "category": "fiction",
"author": "Herman Melville",
"title": "Moby Dick",
"isbn": "0-553-21311-3",
"price": 8.99
},
{ "category": "fiction",
"author": "J. R. R. Tolkien",
"title": "The Lord of the Rings",
"isbn": "0-395-19395-8",
"price": 22.99
}
],
"bicycle": {
"color": "red",
"price": 19.95
}
}
}""",
mimetype="application/json",
)
3 changes: 3 additions & 0 deletions integration/tests_ok/jsonpath_store.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash
set -Eeuo pipefail
hurl tests_ok/jsonpath_store.hurl
3 changes: 0 additions & 3 deletions integration/tests_ok/predicates-string.sh

This file was deleted.

31 changes: 31 additions & 0 deletions integration/tests_ok/predicates_number.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<pre><code class="language-hurl"><span class="hurl-entry"><span class="request"><span class="line"></span><span class="comment"># testing predicates</span>
<span class="line"></span><span class="comment"># on the number types: integer and float</span>
<span class="line"><span class="method">GET</span> <span class="url">http://localhost:8000/predicates-number</span></span>
</span><span class="response"><span class="line"></span>
<span class="line"><span class="version">HTTP</span> <span class="number">200</span></span>
<span class="line"><span class="section-header">[Asserts]</span></span>
<span class="line"></span>
<span class="line"><span class="query-type">jsonpath</span> <span class="string">"$.integer"</span> <span class="predicate-type">exists</span></span>
<span class="line"><span class="query-type">jsonpath</span> <span class="string">"$.integer"</span> <span class="predicate-type">isInteger</span></span>
<span class="line"><span class="query-type">jsonpath</span> <span class="string">"$.integer"</span> <span class="not">not</span> <span class="predicate-type">isFloat</span></span>
<span class="line"><span class="query-type">jsonpath</span> <span class="string">"$.integer"</span> <span class="predicate-type">==</span> <span class="number">1</span></span>
<span class="line"><span class="query-type">jsonpath</span> <span class="string">"$.integer"</span> <span class="predicate-type">&lt;=</span> <span class="number">2</span></span>
<span class="line"><span class="query-type">jsonpath</span> <span class="string">"$.integer"</span> <span class="predicate-type">&gt;</span> <span class="number">0</span></span>
<span class="line"><span class="query-type">jsonpath</span> <span class="string">"$.integer"</span> <span class="predicate-type">&gt;</span> <span class="number">0.0</span></span>
<span class="line"><span class="query-type">jsonpath</span> <span class="string">"$.integer"</span> <span class="predicate-type">!=</span> <span class="null">null</span></span>
<span class="line"></span>
<span class="line"><span class="query-type">jsonpath</span> <span class="string">"$.float"</span> <span class="predicate-type">exists</span></span>
<span class="line"><span class="query-type">jsonpath</span> <span class="string">"$.float"</span> <span class="predicate-type">isFloat</span></span>
<span class="line"><span class="query-type">jsonpath</span> <span class="string">"$.float"</span> <span class="not">not</span> <span class="predicate-type">isInteger</span></span>
<span class="line"><span class="query-type">jsonpath</span> <span class="string">"$.float"</span> <span class="predicate-type">==</span> <span class="number">1.0</span></span>
<span class="line"><span class="query-type">jsonpath</span> <span class="string">"$.float"</span> <span class="predicate-type">&lt;=</span> <span class="number">2.0</span></span>
<span class="line"><span class="query-type">jsonpath</span> <span class="string">"$.float"</span> <span class="predicate-type">&gt;</span> <span class="number">0.0</span></span>
<span class="line"><span class="query-type">jsonpath</span> <span class="string">"$.float"</span> <span class="predicate-type">&gt;</span> <span class="number">0</span></span>
<span class="line"><span class="query-type">jsonpath</span> <span class="string">"$.float"</span> <span class="predicate-type">!=</span> <span class="null">null</span></span>
<span class="line"></span>
<span class="json"><span class="line">{</span>
<span class="line"> "integer": 1,</span>
<span class="line"> "float": 1.0</span>
<span class="line">}</span></span>
</span></span><span class="line"></span>
</code></pre>
30 changes: 30 additions & 0 deletions integration/tests_ok/predicates_number.hurl
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# testing predicates
# on the number types: integer and float
GET http://localhost:8000/predicates-number

HTTP 200
[Asserts]

jsonpath "$.integer" exists
jsonpath "$.integer" isInteger
jsonpath "$.integer" not isFloat
jsonpath "$.integer" == 1
jsonpath "$.integer" <= 2
jsonpath "$.integer" > 0
jsonpath "$.integer" > 0.0
jsonpath "$.integer" != null

jsonpath "$.float" exists
jsonpath "$.float" isFloat
jsonpath "$.float" not isInteger
jsonpath "$.float" == 1.0
jsonpath "$.float" <= 2.0
jsonpath "$.float" > 0.0
jsonpath "$.float" > 0
jsonpath "$.float" != null

{
"integer": 1,
"float": 1.0
}

1 change: 1 addition & 0 deletions integration/tests_ok/predicates_number.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"entries":[{"request":{"method":"GET","url":"http://localhost:8000/predicates-number"},"response":{"status":200,"asserts":[{"query":{"type":"jsonpath","expr":"$.integer"},"predicate":{"type":"exist"}},{"query":{"type":"jsonpath","expr":"$.integer"},"predicate":{"type":"isInteger"}},{"query":{"type":"jsonpath","expr":"$.integer"},"predicate":{"not":true,"type":"isFloat"}},{"query":{"type":"jsonpath","expr":"$.integer"},"predicate":{"type":"equal","value":1}},{"query":{"type":"jsonpath","expr":"$.integer"},"predicate":{"type":"less-or-equal","value":2}},{"query":{"type":"jsonpath","expr":"$.integer"},"predicate":{"type":"greater","value":0}},{"query":{"type":"jsonpath","expr":"$.integer"},"predicate":{"type":"greater","value":0.0}},{"query":{"type":"jsonpath","expr":"$.integer"},"predicate":{"type":"not-equal","value":null}},{"query":{"type":"jsonpath","expr":"$.float"},"predicate":{"type":"exist"}},{"query":{"type":"jsonpath","expr":"$.float"},"predicate":{"type":"isFloat"}},{"query":{"type":"jsonpath","expr":"$.float"},"predicate":{"not":true,"type":"isInteger"}},{"query":{"type":"jsonpath","expr":"$.float"},"predicate":{"type":"equal","value":1.0}},{"query":{"type":"jsonpath","expr":"$.float"},"predicate":{"type":"less-or-equal","value":2.0}},{"query":{"type":"jsonpath","expr":"$.float"},"predicate":{"type":"greater","value":0.0}},{"query":{"type":"jsonpath","expr":"$.float"},"predicate":{"type":"greater","value":0}},{"query":{"type":"jsonpath","expr":"$.float"},"predicate":{"type":"not-equal","value":null}}],"body":{"type":"json","value":{"integer":1,"float":1.0}}}}]}
3 changes: 3 additions & 0 deletions integration/tests_ok/predicates_number.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Set-StrictMode -Version latest
$ErrorActionPreference = 'Stop'
hurl tests_ok/predicates_number.hurl --verbose
13 changes: 13 additions & 0 deletions integration/tests_ok/predicates_number.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from app import app
from flask import Response


@app.route("/predicates-number")
def predicates_number():
return Response(
"""{
"integer": 1,
"float": 1.0
}""",
mimetype="application/json",
)
3 changes: 3 additions & 0 deletions integration/tests_ok/predicates_number.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash
set -Eeuo pipefail
hurl tests_ok/predicates_number.hurl --verbose
3 changes: 3 additions & 0 deletions integration/tests_ok/predicates_string.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Set-StrictMode -Version latest
$ErrorActionPreference = 'Stop'
hurl tests_ok/predicates_string.hurl --verbose
3 changes: 3 additions & 0 deletions integration/tests_ok/predicates_string.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash
set -Eeuo pipefail
hurl tests_ok/predicates_string.hurl --verbose
Loading