Add :cp, refactor evil file commands, add tests
This commit is contained in:
parent
08f760a4ef
commit
94f8e7768b
3 changed files with 86 additions and 22 deletions
|
@ -4,6 +4,25 @@
|
|||
|
||||
(defalias 'do-it '+evil*ex-replace-special-filenames)
|
||||
|
||||
(defmacro do-files! (src dest &rest body)
|
||||
(declare (indent defun))
|
||||
`(let ((it ,src)
|
||||
(other ,dest))
|
||||
(with-temp-file it
|
||||
(insert "Hello world"))
|
||||
|
||||
(unwind-protect
|
||||
(progn
|
||||
(should (file-exists-p it))
|
||||
(find-file-literally it)
|
||||
(should (equal (buffer-string) "Hello world"))
|
||||
(should (equal (buffer-file-name) it))
|
||||
(let ((inhibit-message (not doom-debug-mode)))
|
||||
,@body))
|
||||
(ignore-errors (delete-file it))
|
||||
,(if dest `(ignore-errors (delete-file other))))))
|
||||
|
||||
;;
|
||||
(def-test-group! feature/evil
|
||||
(ert-deftest custom-file-modifiers ()
|
||||
(let ((buffer-file-name "~/.emacs.d/test/modules/feature/test-evil.el")
|
||||
|
@ -48,4 +67,24 @@
|
|||
(should (equal (do-it "%:~") ""))
|
||||
(should (equal (do-it "%:s?e?x?") ""))
|
||||
(should (equal (do-it "%:gs?e?x?") ""))
|
||||
(should (equal (do-it "%:P") "")))))
|
||||
(should (equal (do-it "%:P") ""))))
|
||||
|
||||
(ert-deftest move-this-file ()
|
||||
(do-files! "/tmp/doom-buffer" "/tmp/doom-buffer-new"
|
||||
(should-error (+evil:move-this-file it))
|
||||
(should (+evil:move-this-file other t))
|
||||
(should (file-exists-p other))
|
||||
(should (not (file-exists-p it)))))
|
||||
|
||||
(ert-deftest copy-this-file ()
|
||||
(do-files! "/tmp/doom-buffer-2" "/tmp/doom-buffer-2-new"
|
||||
(should-error (+evil:copy-this-file it))
|
||||
(should (+evil:copy-this-file other t))
|
||||
(should (file-exists-p other))
|
||||
(should (file-exists-p it))))
|
||||
|
||||
(ert-deftest delete-this-file ()
|
||||
(do-files! "/tmp/doom-buffer-3" nil
|
||||
(should-error (+evil:delete-this-file "this-file-does-not-exist"))
|
||||
(should (+evil:delete-this-file nil t))
|
||||
(should (not (file-exists-p it))))))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue