fix: v0.4.2 — frontmatter --add/--remove refuse invalid YAML instead of dropping existing items
This commit is contained in:
1 parent
34d28c03fa
commit
33544edf07
2 files changed
+20
-2
No files matched your search
@@ -249,6 +249,16 @@ Test content"""
|
||||
self.assertEqual([c.args[0] for c in echo.call_args_list],
|
||||
["No change to 'participants' in m", "No change to 'absent' in m"])
|
||||
|
||||
def test_frontmatter_add_refuses_invalid_yaml(self):
|
||||
"""Unparseable frontmatter must not look like 'key missing' and lose existing items"""
|
||||
note = self.test_dir / 'person.md'
|
||||
content = '---\nchildren: "[[Julia]]", "[[Jacob]]"\ntype: person\n---\nCorps\n'
|
||||
note.write_text(content, encoding='utf-8')
|
||||
for remove in (False, True):
|
||||
with self.assertRaises(click.UsageError):
|
||||
self.cli.frontmatter_list_items('person', 'children', ('[[Nouveau]]',), remove=remove)
|
||||
self.assertEqual(note.read_text(encoding='utf-8'), content)
|
||||
|
||||
def test_frontmatter_add_refuses_unquoted_links(self):
|
||||
note = self.test_dir / 'bad.md'
|
||||
content = '---\nrelated:\n - [[Haro]]\n---\n'
|
||||
|
||||
Reference in new issue
Block a user