Skip to content

Commit

Permalink
Add a regression test for `org-export-with-buffer-copy'
Browse files Browse the repository at this point in the history
* testing/lisp/test-ox.el (test-org-export/org-export-copy-buffer):
Make sure that `org-export-with-buffer-copy' does not show up when
Emacs is searching for buffers associated with file.
  • Loading branch information
yantar92 committed Oct 10, 2022
1 parent 192742c commit 8901fd2
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions testing/lisp/test-ox.el
Original file line number Diff line number Diff line change
Expand Up @@ -63,20 +63,32 @@ variable, and communication channel under `info'."

(ert-deftest test-org-export/org-export-copy-buffer ()
"Test `org-export-copy-buffer' specifications."
;; The buffer copy must not cause overwriting the original file
;; buffer under any circumstances.
;; The copy must not overwrite the original file.
(org-test-with-temp-text-in-file
"* Heading"
(let ((file (buffer-file-name)))
(with-current-buffer (org-export-copy-buffer)
(insert "This must not go into actual file.")
(insert "This must not go into the original file.")
(save-buffer)
(should
(equal
"* Heading"
(with-temp-buffer
(insert-file-contents file)
(buffer-string))))))))
(buffer-string)))))))
;; The copy must not show when re-opening the original file.
(org-test-with-temp-text-in-file
"* Heading"
(let ((file (buffer-file-name))
(buffer-copy (generate-new-buffer " *Org export copy*")))
(org-export-with-buffer-copy
:to-buffer buffer-copy
(insert "This must not show as the original file.")
(save-buffer))
;; Unassign the original buffer from file.
(setq buffer-file-name nil)
(should-not
(equal buffer-copy (get-file-buffer file))))))

(ert-deftest test-org-export/bind-keyword ()
"Test reading #+BIND: keywords."
Expand Down

0 comments on commit 8901fd2

Please sign in to comment.