summaryrefslogtreecommitdiffstats
path: root/tests/rules/test_key_duplicates.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/rules/test_key_duplicates.py')
-rw-r--r--tests/rules/test_key_duplicates.py54
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)