api-tuner 0.5.5 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -6
- package/package.json +1 -1
- package/rules/assertions.n3 +8 -5
package/README.md
CHANGED
|
@@ -226,18 +226,15 @@ Assert the presence and value of an HTTP header. Header names are case-insensiti
|
|
|
226
226
|
```
|
|
227
227
|
⚠️ Be careful when using `?res!log:includes` resource path shorthand which will not work inside `tuner:formula`. Please refer to [this discussion](https://github.com/eyereasoner/eye/issues/148#issuecomment-2810940959).
|
|
228
228
|
|
|
229
|
-
<<<<<<< json-assertions
|
|
230
229
|
- **JSON Path**: If the response is JSON, you can use `tuner:jsonPath` to assert values within the body.
|
|
231
230
|
```turtle
|
|
232
|
-
?res tuner:body ?body .
|
|
233
231
|
# Exact match
|
|
234
|
-
?
|
|
232
|
+
?res tuner:jsonPath ( "$.foo" "bar" ) .
|
|
235
233
|
# Custom assertion (e.g. regex, contains, math)
|
|
236
|
-
?
|
|
234
|
+
?res tuner:jsonPath ( "$.baz" "42" string:contains ) .
|
|
237
235
|
```
|
|
236
|
+
⚠️ Note that unlike RDF assersion, JSON Path assertions are used on the response itself, without using `tuner:body`.
|
|
238
237
|
|
|
239
|
-
=======
|
|
240
|
-
>>>>>>> master
|
|
241
238
|
#### Generic Assertions
|
|
242
239
|
|
|
243
240
|
Use `tuner:assertThat` to fail a test with a custom message if a condition is not met.
|
package/package.json
CHANGED
package/rules/assertions.n3
CHANGED
|
@@ -3,6 +3,7 @@ PREFIX list: <http://www.w3.org/2000/10/swap/list#>
|
|
|
3
3
|
PREFIX tuner: <https://api-tuner.described.at/>
|
|
4
4
|
prefix string: <http://www.w3.org/2000/10/swap/string#>
|
|
5
5
|
prefix log: <http://www.w3.org/2000/10/swap/log#>
|
|
6
|
+
prefix file: <http://www.w3.org/2000/10/swap/file#>
|
|
6
7
|
|
|
7
8
|
{
|
|
8
9
|
?expr tuner:assertThat ?msg .
|
|
@@ -74,16 +75,18 @@ prefix log: <http://www.w3.org/2000/10/swap/log#>
|
|
|
74
75
|
} .
|
|
75
76
|
|
|
76
77
|
{
|
|
77
|
-
?
|
|
78
|
+
?res tuner:jsonPath ( ?path ?expected ) .
|
|
78
79
|
} <= {
|
|
79
|
-
?
|
|
80
|
+
?res tuner:jsonPath ( ?path ?expected log:equalTo ) .
|
|
80
81
|
} .
|
|
81
82
|
|
|
82
83
|
{
|
|
83
|
-
?
|
|
84
|
+
?res tuner:jsonPath ( ?path ?expected ?builtIn ) .
|
|
84
85
|
} <= {
|
|
85
|
-
?
|
|
86
|
-
|
|
86
|
+
?res log:includes {
|
|
87
|
+
[] a tuner:Response ; tuner:body ?bodyPath .
|
|
88
|
+
} .
|
|
89
|
+
( "cat " ?bodyPath " | " "bin/jsonpath.sh"!file:libPath " '" ?path "' " )!string:concatenation log:shell ?actualRaw .
|
|
87
90
|
|
|
88
91
|
# remove surrounding quotes added by the shell
|
|
89
92
|
( ( ?actualRaw '^\"' "")!string:replace '\"$' "") string:replace ?actual .
|