From 54a6eeaf1da3add0fc9af6eac181fed8a4e80a8d Mon Sep 17 00:00:00 2001 From: Dustin Farris Date: Tue, 1 Jul 2025 21:35:16 -0700 Subject: [PATCH] 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. --- tests/test-org-roam-node.el | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/tests/test-org-roam-node.el b/tests/test-org-roam-node.el index 8f71c5d..31972b0 100644 --- a/tests/test-org-roam-node.el +++ b/tests/test-org-roam-node.el @@ -73,14 +73,16 @@ (expect (org-roam-node-title node) :to-equal "Bruce Wayne")))) (describe "org-roam-demote-entire-buffer" - (after-each - (cd root-directory)) - (it "demotes an entire org buffer" - (find-file "tests/roam-files/demoteable.org" nil) - (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"))) + ;; Use a temporary copy to avoid interfering with other tests + (let ((temp-file (make-temp-file "test-demoteable-" nil ".org"))) + (copy-file "tests/roam-files/demoteable.org" temp-file t) + (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" (after-each