test: fix org-roam-demote-entire-buffer leaving git dirty

The test was modifying tests/roam-files/demoteable.org directly,
causing the file to be left in a modified state after test runs.
This left git in a dirty state and caused subsequent test failures
when the database expected the original file contents.

Changed the test to use a temporary copy of the file instead,
ensuring the original test data remains unmodified.
This commit is contained in:
Dustin Farris
2025-07-01 21:35:16 -07:00
parent 89dfaef38b
commit 54a6eeaf1d

View File

@ -73,14 +73,16 @@
(expect (org-roam-node-title node) :to-equal "Bruce Wayne")))) (expect (org-roam-node-title node) :to-equal "Bruce Wayne"))))
(describe "org-roam-demote-entire-buffer" (describe "org-roam-demote-entire-buffer"
(after-each
(cd root-directory))
(it "demotes an entire org buffer" (it "demotes an entire org buffer"
(find-file "tests/roam-files/demoteable.org" nil) ;; Use a temporary copy to avoid interfering with other tests
(org-roam-demote-entire-buffer) (let ((temp-file (make-temp-file "test-demoteable-" nil ".org")))
(expect (buffer-substring-no-properties (point) (point-max)) (copy-file "tests/roam-files/demoteable.org" temp-file t)
:to-equal "* Demoteable\n:PROPERTIES:\n:ID: 97bf31cf-dfee-45d8-87a5-2ae0dabc4734\n:END:\n\n** Demoteable h1\n\n*** Demoteable child\n"))) (find-file temp-file)
(org-roam-demote-entire-buffer)
(expect (buffer-substring-no-properties (point) (point-max))
:to-equal "* Demoteable\n:PROPERTIES:\n:ID: 97bf31cf-dfee-45d8-87a5-2ae0dabc4734\n:END:\n\n** Demoteable h1\n\n*** Demoteable child\n")
(kill-buffer)
(delete-file temp-file))))
(describe "org-roam--h1-count" (describe "org-roam--h1-count"
(after-each (after-each