check-and-semantics
Tests one check in the rule vocabulary: how it decides, and what it reports.
Our implementation passes this case when its check --json output for the input below equals the expected
output.
Input
nodes/a.md---
id: a
type: svc
fields:
owner: x
tier: 1
---nodes/b.md---
id: b
type: svc
fields:
owner: x
tier: 3
---nodes/c.md---
id: c
type: svc
fields:
tier: 1
---nodes/r.md---
id: r
type: rule
fields:
statement: s
applies_to: {type: svc}
check: {require_fields: [owner], field_is: {tier: {in: [1, 2]}}}
---Expected output
0 ghosts · 0 load errors · 4 nodes · 3 results
expected.json{
"ghosts": [],
"load_errors": [],
"nodes": [
{
"body": "",
"fields": {
"owner": "x",
"tier": 1
},
"id": "a",
"links": [],
"parent": null,
"plane": null,
"title": "a",
"type": "svc"
},
{
"body": "",
"fields": {
"owner": "x",
"tier": 3
},
"id": "b",
"links": [],
"parent": null,
"plane": null,
"title": "b",
"type": "svc"
},
{
"body": "",
"fields": {
"tier": 1
},
"id": "c",
"links": [],
"parent": null,
"plane": null,
"title": "c",
"type": "svc"
},
{
"body": "",
"fields": {
"applies_to": {
"type": "svc"
},
"check": {
"field_is": {
"tier": {
"in": [
1,
2
]
}
},
"require_fields": [
"owner"
]
},
"statement": "s"
},
"id": "r",
"links": [],
"parent": null,
"plane": null,
"title": "r",
"type": "rule"
}
],
"results": [
{
"node": "a",
"rule": "r",
"severity": "warn",
"status": "pass"
},
{
"node": "b",
"rule": "r",
"severity": "warn",
"status": "fail"
},
{
"node": "c",
"rule": "r",
"severity": "warn",
"status": "fail"
}
],
"structure": {
"errors": [],
"warnings": []
}
}