summaryrefslogtreecommitdiffstats
path: root/tests/test_frontmatter.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_frontmatter.py')
-rw-r--r--tests/test_frontmatter.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/tests/test_frontmatter.py b/tests/test_frontmatter.py
index 2257a8a..6cd4b44 100644
--- a/tests/test_frontmatter.py
+++ b/tests/test_frontmatter.py
@@ -1,6 +1,5 @@
import pytest
from pathlib import Path
-import tempfile
from core.frontmatter import parse_frontmatter, write_frontmatter
SAMPLE_MD = """\
@@ -42,6 +41,13 @@ def test_write_preserves_format(tmp_path):
assert fm2["title"] == "Updated Title"
assert fm2["type"] == "Tech"
+def test_write_is_idempotent(tmp_path):
+ f = tmp_path / "index.md"
+ f.write_text(SAMPLE_MD)
+ fm, body = parse_frontmatter(f)
+ write_frontmatter(f, fm, body)
+ assert f.read_text() == SAMPLE_MD
+
def test_parse_raises_on_missing_delimiters(tmp_path):
f = tmp_path / "index.md"
f.write_text("# No frontmatter\n\nJust body.")