Skip to content

Commit 6be74a8

Browse files
committed
test(cli): add test case for list preservation in merge_json_files
1 parent 64dd3ab commit 6be74a8

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

tests/test_merge.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,3 +120,16 @@ def test_merge_json_files_unparseable_existing(tmp_path):
120120

121121
assert merge_json_files(bad_file, {"b": 2}) is None
122122

123+
124+
def test_merge_json_files_list_preservation(tmp_path):
125+
"""Verify that existing list values are preserved and NOT merged or overwritten."""
126+
existing_file = tmp_path / "list.json"
127+
existing_file.write_text('{"my.list": ["user_item"]}')
128+
129+
template_settings = {
130+
"my.list": ["template_item"]
131+
}
132+
133+
merged = merge_json_files(existing_file, template_settings)
134+
# The polite merge policy says: keep existing values if they exist and aren't both dicts
135+
assert merged["my.list"] == ["user_item"]

0 commit comments

Comments
 (0)