diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-14 19:07:17 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-14 19:07:17 +0000 |
commit | 2e8bb0941c5a991bc317e5edea246972d78e769b (patch) | |
tree | 4fe98f76327452bce9489ab93c48ff403c7d577b /tests/rules/test_key_duplicates.py | |
parent | Releasing progress-linux version 1.33.0-1~progress7.99u1. (diff) | |
download | yamllint-2e8bb0941c5a991bc317e5edea246972d78e769b.tar.xz yamllint-2e8bb0941c5a991bc317e5edea246972d78e769b.zip |
Merging upstream version 1.35.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/rules/test_key_duplicates.py')
-rw-r--r-- | tests/rules/test_key_duplicates.py | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/tests/rules/test_key_duplicates.py b/tests/rules/test_key_duplicates.py index 3f8a9e6..c1704e6 100644 --- a/tests/rules/test_key_duplicates.py +++ b/tests/rules/test_key_duplicates.py @@ -179,3 +179,57 @@ class KeyDuplicatesTestCase(RuleTestCase): '[\n' ' flow: sequence, with, key: value, mappings\n' ']\n', conf) + + def test_forbid_duplicated_merge_keys(self): + conf = 'key-duplicates: {forbid-duplicated-merge-keys: true}' + self.check('---\n' + 'Multiple Merge Keys are NOT OK:\n' + 'anchor_one: &anchor_one\n' + ' one: one\n' + 'anchor_two: &anchor_two\n' + ' two: two\n' + 'anchor_reference:\n' + ' <<: *anchor_one\n' + ' <<: *anchor_two\n', conf, problem=(9, 3)) + self.check('---\n' + 'Multiple Merge Keys are NOT OK:\n' + 'anchor_one: &anchor_one\n' + ' one: one\n' + 'anchor_two: &anchor_two\n' + ' two: two\n' + 'anchor_three: &anchor_three\n' + ' two: three\n' + 'anchor_reference:\n' + ' <<: *anchor_one\n' + ' <<: *anchor_two\n' + ' <<: *anchor_three\n', conf, + problem1=(11, 3), problem2=(12, 3)) + self.check('---\n' + 'Multiple Merge Keys are NOT OK:\n' + 'anchor_one: &anchor_one\n' + ' one: one\n' + 'anchor_two: &anchor_two\n' + ' two: two\n' + 'anchor_reference:\n' + ' a: 1\n' + ' <<: *anchor_one\n' + ' b: 2\n' + ' <<: *anchor_two\n', conf, problem=(11, 3)) + self.check('---\n' + 'Single Merge Key is OK:\n' + 'anchor_one: &anchor_one\n' + ' one: one\n' + 'anchor_two: &anchor_two\n' + ' two: two\n' + 'anchor_reference:\n' + ' <<: [*anchor_one, *anchor_two]\n', conf) + self.check('---\n' + 'Duplicate keys without Merge Keys:\n' + ' key: a\n' + ' otherkey: b\n' + ' key: c\n', conf, + problem=(5, 3)) + self.check('---\n' + 'No Merge Keys:\n' + ' key: a\n' + ' otherkey: b\n', conf) |