Skip to content

Commit c7bae83

Browse files
test: provide for situation where there is no right operand in base
1 parent f5db96e commit c7bae83

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

test.py

+27
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import copy
22
import unittest
3+
4+
import yaml
5+
36
from yamldifftool import filter_defaults
47

58
class TestYamlDiffTool(unittest.TestCase):
@@ -57,5 +60,29 @@ def test_filter_defaults_with_strict_mode(self):
5760
filter_defaults(self.base_yaml, user_yaml, root_diff, strict=True)
5861
self.assertEqual(root_diff, {})
5962

63+
def test_none_handling_in_base(self):
64+
base_yaml = yaml.safe_load("""
65+
global:
66+
identity:
67+
auth:
68+
operate:
69+
existingSecret:
70+
image:
71+
tag: 8.2.2
72+
""")
73+
user_yaml = yaml.safe_load("""
74+
global:
75+
identity:
76+
auth:
77+
operate:
78+
existingSecret:
79+
name: nameofsecret
80+
image:
81+
tag: 8.3.2
82+
""")
83+
root_diff = {}
84+
filter_defaults(base_yaml, user_yaml, root_diff)
85+
self.assertEqual(root_diff, {"global": {"image": {"tag": "8.3.2"}}})
86+
6087
if __name__ == '__main__':
6188
unittest.main()

0 commit comments

Comments
 (0)