Skip to content

Commit

Permalink
feat: tuner:assertThat
Browse files Browse the repository at this point in the history
  • Loading branch information
tpluscode committed Feb 10, 2025
1 parent 676bc0a commit 51493a9
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/lemon-garlics-grab.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"api-tuner": patch
---

Added `tuner:assertThat` backward rule
17 changes: 17 additions & 0 deletions rules/assertions.n3
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,23 @@ PREFIX tuner: <https://api-tuner.described.at/>
prefix string: <http://www.w3.org/2000/10/swap/string#>
prefix log: <http://www.w3.org/2000/10/swap/log#>

{
?expr tuner:assertThat ?msg .
} <= {
(
?expr
true
{
(
{ ?msg log:rawType log:ForAll }
{ ?expr^tuner:logFailedAssertion }
{ ?msg^tuner:logFailedAssertion }
) log:ifThenElseIn [].
true log:equalTo false .
}
) log:ifThenElseIn [] .
} .

{
?res tuner:http_code ?value .
} <= {
Expand Down
10 changes: 10 additions & 0 deletions rules/logging.n3
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,13 @@ prefix string: <http://www.w3.org/2000/10/swap/string#>
true
) log:ifThenElseIn ?SCOPE .
} .

{
?left tuner:logFailedAssertion ?right .
} <= {
(
{ [] tuner:logLevel 'info' }
{ 'Failed assertion' log:trace ?right . }
true
) log:ifThenElseIn ?SCOPE .
} .
1 change: 1 addition & 0 deletions tests/http_code.n3
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
PREFIX res: <http://dbpedia.org/resource/>
prefix : <https://api-tuner.described.at/test#http-code/>
PREFIX earl: <http://www.w3.org/ns/earl#>
PREFIX tuner: <https://api-tuner.described.at/>
Expand Down

0 comments on commit 51493a9

Please sign in to comment.