diff --git a/ChangeLog b/ChangeLog index 2ffbec98..b5be0527 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2026-05-11 Mats Lidell +* test/hyrolo-tests.el (hyrolo-tests--mail-to): Test error case. + (hyrolo-tests--rename): Add test. + * test/hyrolo-tests.el: Verify all return values for hyrolo-grep and hyrolo-fgrep. diff --git a/test/hyrolo-tests.el b/test/hyrolo-tests.el index 734affcc..4234552e 100644 --- a/test/hyrolo-tests.el +++ b/test/hyrolo-tests.el @@ -1671,7 +1671,12 @@ body (mocklet (((actypes::link-to-compose-mail "second@receiver.org") => t)) (hyrolo-mail-to))) (kill-buffer hyrolo-display-buffer) - (hy-delete-files-and-buffers hyrolo-file-list)))) + (hy-delete-files-and-buffers hyrolo-file-list))) + (with-temp-buffer + (mocklet (((beep) => t)) + (ert-with-message-capture cap + (hyrolo-mail-to) + (hy-test-helpers:should-last-message "Invalid buffer or no e-mail address found" cap))))) (ert-deftest hyrolo-tests--location-movement () "Verify movement between location headers." @@ -2094,6 +2099,27 @@ Dependencies on the consult package are mocked." (hyrolo-set-date) (should (string= "* item\n\t\t\t2025-01-03\n\n\n" (buffer-string)))))))) +(ert-deftest hyrolo-tests--rename () + "Verify `hyrolo-rename' changes the name of the old rolo file." + (defvar new-file) + (let* ((old-file (make-temp-file "hypb" nil ".otl" "old-file")) + (old-file-backup (concat old-file "~")) + (new-file (concat (expand-file-name (make-temp-name "hypb") "/tmp") ".otl")) + (new-file-backup (concat new-file "~"))) + (unwind-protect + (with-mock + (mock (hyrolo-get-file-list) => (list new-file)) + (mock (hyrolo-prompt 'y-or-n-p *) => t) + (make-empty-file old-file-backup) + (find-file-noselect old-file) + (ert-with-message-capture cap + (hyrolo-rename old-file new-file) + (should (string-search "Your personal rolo file is now" cap))) + (should (file-exists-p new-file-backup)) + (with-current-buffer (find-file new-file) + (should (looking-at-p "old-file")))) + (hy-delete-files-and-buffers (list old-file old-file-backup new-file new-file-backup))))) + (provide 'hyrolo-tests) ;; This file can't be byte-compiled without the `el-mock' package