-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Custom rules may skip related_resources (#210)
Don't generate docs link for custom rules. Allow them to provide their own, but if they don't it should be allowed to be blank. Fixes #207 Signed-off-by: Anders Eknert <anders@styra.com>
- Loading branch information
1 parent
9bdbe30
commit 6fdb963
Showing
3 changed files
with
100 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
package regal.result_test | ||
|
||
import data.regal.result | ||
|
||
test_no_related_resources_in_result_fail_on_custom_rule_unless_provided { | ||
chain := [ | ||
{"path": ["custom", "regal", "rules", "categoy", "name", "report"]}, | ||
{ | ||
"annotations": { | ||
"scope": "package", | ||
"description": "This is a test", | ||
}, | ||
"path": ["custom", "regal", "rules", "categoy", "name"], | ||
}, | ||
] | ||
|
||
violation := result.fail(chain, {}) | ||
|
||
violation == { | ||
"category": "categoy", | ||
"description": "This is a test", | ||
"level": "error", | ||
"title": "name", | ||
} | ||
} | ||
|
||
test_related_resources_in_result_fail_on_custom_rule_when_provided { | ||
chain := [ | ||
{"path": ["custom", "regal", "rules", "categoy", "name", "report"]}, | ||
{ | ||
"annotations": { | ||
"scope": "package", | ||
"description": "This is a test", | ||
"related_resources": [{ | ||
"description": "documentation", | ||
"ref": "https://example.com", | ||
}], | ||
}, | ||
"path": ["custom", "regal", "rules", "categoy", "name"], | ||
}, | ||
] | ||
|
||
violation := result.fail(chain, {}) | ||
|
||
violation == { | ||
"category": "categoy", | ||
"description": "This is a test", | ||
"level": "error", | ||
"related_resources": [{ | ||
"description": "documentation", | ||
"ref": "https://example.com", | ||
}], | ||
"title": "name", | ||
} | ||
} | ||
|
||
test_related_resources_generated_by_result_fail_for_builtin_rule { | ||
chain := [ | ||
{"path": ["regal", "rules", "categoy", "name", "report"]}, | ||
{ | ||
"annotations": { | ||
"scope": "package", | ||
"description": "This is a test", | ||
}, | ||
"path": ["regal", "rules", "categoy", "name"], | ||
}, | ||
] | ||
|
||
violation := result.fail(chain, {}) | ||
|
||
violation == { | ||
"category": "categoy", | ||
"description": "This is a test", | ||
"level": "error", | ||
"related_resources": [{ | ||
"description": "documentation", | ||
"ref": "https://github.com/StyraInc/regal/blob/main/docs/rules/categoy/name.md", | ||
}], | ||
"title": "name", | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters