-
Notifications
You must be signed in to change notification settings - Fork 598
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
43 additions
and
1 deletion.
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,42 @@ | ||
""" | ||
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
SPDX-License-Identifier: MIT-0 | ||
""" | ||
|
||
import pytest | ||
|
||
from cfnlint.rules.formats.LogGroupName import LogGroupName | ||
|
||
|
||
@pytest.fixture(scope="module") | ||
def rule(): | ||
rule = LogGroupName() | ||
yield rule | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"name,instance,expected", | ||
[ | ||
( | ||
"Valid log group name", | ||
"123457", | ||
True, | ||
), | ||
( | ||
"Valid with invalid type", | ||
[], | ||
True, | ||
), | ||
( | ||
"Valid log group name with special characters", | ||
"aws/one.two-three#four_five", | ||
True, | ||
), | ||
("Invalid log group name because of special character", "foo&bar", False), | ||
("Invalid log group name because of empty", "", False), | ||
("Invalid log group name because too long", "a" * 513, False), | ||
], | ||
) | ||
def test_validate(name, instance, expected, rule, validator): | ||
result = rule.format(validator, instance) | ||
assert result == expected, f"Test {name!r} got {result!r}" |