Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
2026-05-11 Mats Lidell <matsl@gnu.org>

* 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.

Expand Down
28 changes: 27 additions & 1 deletion test/hyrolo-tests.el
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down Expand Up @@ -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
Expand Down