-
Notifications
You must be signed in to change notification settings - Fork 577
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow over ride of location in rule matching (#2410)
- Loading branch information
Showing
2 changed files
with
36 additions
and
2 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,30 @@ | ||
""" | ||
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
SPDX-License-Identifier: MIT-0 | ||
""" | ||
from typing import Any | ||
from test.testlib.testcase import BaseTestCase | ||
from cfnlint.rules import CloudFormationLintRule, Match, RuleMatch, matching | ||
|
||
|
||
class rule(CloudFormationLintRule): | ||
id: str = 'ETest' | ||
pass | ||
|
||
rule_match = RuleMatch([], 'Message', rule=rule(), location=(0, 0, 0, 0)) | ||
|
||
class TestMatching(BaseTestCase): | ||
"""Test Matching Wrapper""" | ||
|
||
def setUp(self) -> None: | ||
return super().setUp() | ||
|
||
def test(self: Any, *args: Any, **kwargs: Any): | ||
return [rule_match] | ||
|
||
def test_matching_location(self): | ||
|
||
f = matching('test') | ||
r = f(self.test) | ||
t = r(self, '', None) | ||
self.assertEqual(t, [Match(1, 1, 1, 1, '', rule(), 'Message', rule_match)]) |