Refactor and fix unit tests, plus isolate them better
This commit is contained in:
parent
5c74814860
commit
8ad2666f8f
14 changed files with 146 additions and 117 deletions
|
@ -74,17 +74,30 @@ If neither is available, run all tests in all enabled modules."
|
|||
(defmacro def-test! (name &rest body)
|
||||
"Define a namespaced ERT test."
|
||||
(declare (indent defun) (doc-string 2))
|
||||
(unless (plist-get body :disabled)
|
||||
(when (plist-get body :skip)
|
||||
(push '(ert-skip nil) body))
|
||||
(let (plist)
|
||||
(while (keywordp (car body))
|
||||
(push (pop body) plist))
|
||||
(setq plist (reverse plist))
|
||||
(when (plist-get plist :skip)
|
||||
(setq body `((ert-skip nil) ,@body)))
|
||||
(when-let* ((modes (doom-enlist (plist-get plist :minor-mode))))
|
||||
(dolist (mode modes)
|
||||
(setq body `((with-minor-mode! ,mode ,@body)))))
|
||||
(when-let* ((before (plist-get plist :before)))
|
||||
(setq body `(,@before ,@body)))
|
||||
(when-let* ((after (plist-get plist :after)))
|
||||
(setq body `(,@body @after)))
|
||||
`(ert-deftest
|
||||
,(cl-loop with path = (file-relative-name (file-name-sans-extension load-file-name)
|
||||
doom-emacs-dir)
|
||||
for (rep . with) in '(("/test/" . "/") ("/" . ":"))
|
||||
do (setq path (replace-regexp-in-string rep with path t t))
|
||||
finally return (intern (format "%s::%s" path name))) ()
|
||||
()
|
||||
,@body)))
|
||||
finally return (intern (format "%s::%s" path name)))
|
||||
()
|
||||
(with-temp-buffer
|
||||
(save-mark-and-excursion
|
||||
(save-window-excursion
|
||||
,@body))))))
|
||||
|
||||
(defmacro should-buffer! (initial expected &rest body)
|
||||
"Test that a buffer with INITIAL text, run BODY, then test it against EXPECTED.
|
||||
|
@ -144,3 +157,10 @@ marker. e.g. {2} can be retrieved with (point! 2)."
|
|||
((symbolp index) (symbol-name index))
|
||||
((stringp index) index))
|
||||
marker-list)))
|
||||
|
||||
(defmacro with-minor-mode! (mode &rest body)
|
||||
"TODO"
|
||||
(declare (indent defun))
|
||||
`(progn (,mode +1)
|
||||
,@body
|
||||
(,mode -1)))
|
||||
|
|
|
@ -1,24 +1,23 @@
|
|||
;; -*- no-byte-compile: t; -*-
|
||||
;;; core/test/autoload-buffers.el
|
||||
|
||||
(defmacro -with-temp-buffers! (buffer-args &rest body)
|
||||
(defmacro with-temp-buffers!! (buffer-args &rest body)
|
||||
(declare (indent defun))
|
||||
(let (buffers)
|
||||
(dolist (bsym buffer-args)
|
||||
(push `(,bsym (get-buffer-create ,(symbol-name bsym)))
|
||||
buffers))
|
||||
`(save-window-excursion
|
||||
(cl-flet ((buffer-list
|
||||
(lambda ()
|
||||
(cl-remove-if-not #'buffer-live-p (list ,@(reverse (mapcar #'car buffers)))))))
|
||||
(let* (persp-mode
|
||||
,@buffers)
|
||||
,@body
|
||||
(mapc #'kill-buffer (buffer-list)))))))
|
||||
`(cl-flet ((buffer-list
|
||||
(lambda ()
|
||||
(cl-remove-if-not #'buffer-live-p (list ,@(reverse (mapcar #'car buffers)))))))
|
||||
(let* (persp-mode
|
||||
,@buffers)
|
||||
,@body
|
||||
(mapc #'kill-buffer (buffer-list))))))
|
||||
|
||||
;;
|
||||
(def-test! get-buffers
|
||||
(-with-temp-buffers! (a b c)
|
||||
(with-temp-buffers!! (a b c)
|
||||
(should (cl-every #'buffer-live-p (buffer-list)))
|
||||
(should (equal (buffer-list) (list a b c)))
|
||||
(dolist (buf (list (cons a doom-emacs-dir)
|
||||
|
@ -26,6 +25,7 @@
|
|||
(cons c "/tmp/")))
|
||||
(with-current-buffer (car buf)
|
||||
(setq-local default-directory (cdr buf))))
|
||||
(projectile-mode +1)
|
||||
(with-current-buffer a
|
||||
;; should produce all buffers
|
||||
(let ((buffers (doom-buffer-list)))
|
||||
|
@ -37,11 +37,12 @@
|
|||
;; If no project is available, just get all buffers
|
||||
(with-current-buffer c
|
||||
(let ((buffers (doom-project-buffer-list)))
|
||||
(should (cl-every (lambda (x) (memq x buffers)) (list a b c)))))))
|
||||
(should (cl-every (lambda (x) (memq x buffers)) (list a b c)))))
|
||||
(projectile-mode -1)))
|
||||
|
||||
(def-test! real-buffers
|
||||
(let (doom-real-buffer-functions)
|
||||
(-with-temp-buffers! (a b c d)
|
||||
(with-temp-buffers!! (a b c d)
|
||||
(dolist (buf (list a b))
|
||||
(with-current-buffer buf
|
||||
(setq-local buffer-file-name "x")))
|
||||
|
@ -62,7 +63,7 @@
|
|||
;; `doom-visible-buffers'
|
||||
;; `doom-buried-buffers'
|
||||
(def-test! visible-buffers-and-windows
|
||||
(-with-temp-buffers! (a b c d)
|
||||
(with-temp-buffers!! (a b c d)
|
||||
(switch-to-buffer a)
|
||||
(should (eq (current-buffer) a))
|
||||
(should (eq (selected-window) (get-buffer-window a)))
|
||||
|
@ -77,7 +78,7 @@
|
|||
|
||||
;; `doom-matching-buffers'
|
||||
(def-test! matching-buffers
|
||||
(-with-temp-buffers! (a b c)
|
||||
(with-temp-buffers!! (a b c)
|
||||
(let ((buffers (doom-matching-buffers "^[ac]$")))
|
||||
(should (= 2 (length buffers)))
|
||||
(should (cl-every #'bufferp buffers))
|
||||
|
@ -86,7 +87,7 @@
|
|||
|
||||
;; `doom-buffers-in-mode'
|
||||
(def-test! buffers-in-mode
|
||||
(-with-temp-buffers! (a b c d e)
|
||||
(with-temp-buffers!! (a b c d e)
|
||||
(dolist (buf (list a b))
|
||||
(with-current-buffer buf
|
||||
(emacs-lisp-mode)))
|
||||
|
@ -101,7 +102,7 @@
|
|||
|
||||
;; `doom-kill-buffer'
|
||||
(def-test! kill-buffer
|
||||
(-with-temp-buffers! (a b)
|
||||
(with-temp-buffers!! (a b)
|
||||
(doom-kill-buffer a)
|
||||
(should-not (buffer-live-p a))
|
||||
;; modified buffer
|
||||
|
@ -112,7 +113,7 @@
|
|||
|
||||
;; `doom--cycle-real-buffers'
|
||||
(def-test! kill-buffer-then-show-real-buffer
|
||||
(-with-temp-buffers! (a b c d)
|
||||
(with-temp-buffers!! (a b c d)
|
||||
(dolist (buf (list a b d))
|
||||
(with-current-buffer buf
|
||||
(setq-local buffer-file-name "x")))
|
||||
|
|
|
@ -2,18 +2,16 @@
|
|||
;;; core/test/autoload-debug.el
|
||||
|
||||
(def-test! what-face
|
||||
(with-temp-buffer
|
||||
(insert (propertize "Hello " 'face 'font-lock-keyword-face))
|
||||
(insert "world")
|
||||
(insert (propertize "Hello " 'face 'font-lock-keyword-face))
|
||||
(insert "world")
|
||||
|
||||
(should (equal (doom/what-face (point-min)) '((font-lock-keyword-face) ())))
|
||||
(should-not (doom/what-face (point-max)))))
|
||||
(should (equal (doom/what-face (point-min)) '((font-lock-keyword-face) ())))
|
||||
(should-not (doom/what-face (point-max))))
|
||||
|
||||
(def-test! what-face-overlays
|
||||
(with-temp-buffer
|
||||
(insert "Hello world")
|
||||
(let ((ov (make-overlay 1 6)))
|
||||
(overlay-put ov 'face 'font-lock-keyword-face))
|
||||
(insert "Hello world")
|
||||
(let ((ov (make-overlay 1 6)))
|
||||
(overlay-put ov 'face 'font-lock-keyword-face))
|
||||
|
||||
(should (equal (doom/what-face (point-min)) '(() (font-lock-keyword-face))))
|
||||
(should-not (doom/what-face (point-max)))))
|
||||
(should (equal (doom/what-face (point-min)) '(() (font-lock-keyword-face))))
|
||||
(should-not (doom/what-face (point-max))))
|
||||
|
|
|
@ -1,31 +1,21 @@
|
|||
;; -*- no-byte-compile: t; -*-
|
||||
;;; core/test/autoload-package.el
|
||||
|
||||
(defun -new-package (name version &optional reqs)
|
||||
(defun -pkg (name version &optional reqs)
|
||||
(package-desc-create :name name :version version :reqs reqs))
|
||||
|
||||
(defmacro -with-temp-packages! (&rest forms)
|
||||
"Run FORMS in the context of a temporary package setup (as in, it won't
|
||||
affects your Emacs packages)."
|
||||
`(let* ((doom-local-dir ,(expand-file-name "test/.local/" doom-emacs-dir))
|
||||
(doom-packages-dir (concat doom-local-dir "packages/"))
|
||||
(doom-etc-dir (concat doom-local-dir "etc/"))
|
||||
(doom-cache-dir (concat doom-local-dir "cache/"))
|
||||
(package-user-dir (expand-file-name "elpa" doom-packages-dir))
|
||||
(quelpa-dir (expand-file-name "quelpa" doom-packages-dir))
|
||||
package-alist
|
||||
package-archive-contents
|
||||
package-initialize)
|
||||
(package-initialize)
|
||||
,@forms))
|
||||
|
||||
(defmacro -with-packages! (packages package-descs &rest body)
|
||||
`(let ((doom-packages ,packages)
|
||||
(defmacro with-packages!! (packages package-descs &rest body)
|
||||
`(let* ((doom-packages-dir ,(expand-file-name "packages/" (file-name-directory load-file-name)))
|
||||
(package-user-dir ,(expand-file-name "elpa" doom-packages-dir))
|
||||
(quelpa-dir ,(expand-file-name "quelpa" doom-packages-dir)))
|
||||
;; (make-directory doom-packages-dir t)
|
||||
(let ((doom-packages ,packages)
|
||||
(package-alist ,package-descs)
|
||||
doom-core-packages)
|
||||
(cl-letf (((symbol-function 'doom-initialize-packages) (lambda (&rest _)))
|
||||
((symbol-function 'package-installed-p) (lambda (name &rest _) (assq name package-alist))))
|
||||
,@body)))
|
||||
(cl-letf (((symbol-function 'doom-initialize-packages) (lambda (&rest _))))
|
||||
,@body))
|
||||
;; (delete-directory doom-packages-dir t)
|
||||
))
|
||||
|
||||
|
||||
;;
|
||||
|
@ -33,18 +23,19 @@ affects your Emacs packages)."
|
|||
;;
|
||||
|
||||
(def-test! backend-detection
|
||||
(let ((package-alist `((doom-dummy ,(-new-package 'doom-dummy '(20160405 1234)))))
|
||||
(let ((package-alist `((doom-dummy ,(-pkg 'doom-dummy '(20160405 1234)))))
|
||||
(quelpa-cache '((doom-quelpa-dummy :fetcher github :repo "hlissner/does-not-exist")))
|
||||
(quelpa-initialized-p t))
|
||||
(should (eq (doom-package-backend 'doom-dummy) 'elpa))
|
||||
(should (eq (doom-package-backend 'doom-quelpa-dummy) 'quelpa))))
|
||||
(should (eq (doom-package-backend 'doom-quelpa-dummy) 'quelpa))
|
||||
(should (eq (doom-package-backend 'org) 'emacs))))
|
||||
|
||||
(def-test! elpa-outdated-detection
|
||||
(let* ((doom--last-refresh (current-time))
|
||||
(package-alist
|
||||
`((doom-dummy ,(-new-package 'doom-dummy '(20160405 1234)))))
|
||||
`((doom-dummy ,(-pkg 'doom-dummy '(20160405 1234)))))
|
||||
(package-archive-contents
|
||||
`((doom-dummy ,(-new-package 'doom-dummy '(20170405 1234))))))
|
||||
`((doom-dummy ,(-pkg 'doom-dummy '(20170405 1234))))))
|
||||
(cl-letf (((symbol-function 'package-refresh-contents) (lambda (&rest _))))
|
||||
(should (equal (doom-package-outdated-p 'doom-dummy)
|
||||
'(doom-dummy (20160405 1234) (20170405 1234)))))))
|
||||
|
@ -53,7 +44,7 @@ affects your Emacs packages)."
|
|||
|
||||
(def-test! get-packages
|
||||
(let ((quelpa-initialized-p t))
|
||||
(-with-packages!
|
||||
(with-packages!!
|
||||
'((doom-dummy))
|
||||
'((doom-dummy nil)
|
||||
(doom-dummy-unwanted nil)
|
||||
|
@ -63,17 +54,17 @@ affects your Emacs packages)."
|
|||
(def-test! orphaned-packages
|
||||
"Test `doom-get-orphaned-packages', which gets a list of packages that are
|
||||
no longer enabled or depended on."
|
||||
(-with-packages!
|
||||
(with-packages!!
|
||||
'((doom-dummy))
|
||||
`((doom-dummy ,(-new-package 'doom-dummy '(20160405 1234) '((doom-dummy-dep (1 0)))))
|
||||
(doom-dummy-unwanted ,(-new-package 'doom-dummy-unwanted '(20160601 1234)))
|
||||
(doom-dummy-dep ,(-new-package 'doom-dummy-dep '(20160301 1234))))
|
||||
`((doom-dummy ,(-pkg 'doom-dummy '(20160405 1234) '((doom-dummy-dep (1 0)))))
|
||||
(doom-dummy-unwanted ,(-pkg 'doom-dummy-unwanted '(20160601 1234)))
|
||||
(doom-dummy-dep ,(-pkg 'doom-dummy-dep '(20160301 1234))))
|
||||
(should (equal (doom-get-orphaned-packages) '(doom-dummy-unwanted)))))
|
||||
|
||||
(def-test! missing-packages
|
||||
"Test `doom-get-missing-packages, which gets a list of enabled packages that
|
||||
aren't installed."
|
||||
(-with-packages!
|
||||
(with-packages!!
|
||||
'((doom-dummy) (doom-dummy-installed))
|
||||
`((doom-dummy-installed ,(-new-package 'doom-dummy-installed '(20160405 1234))))
|
||||
`((doom-dummy-installed ,(-pkg 'doom-dummy-installed '(20160405 1234))))
|
||||
(should (equal (doom-get-missing-packages) '((doom-dummy))))))
|
||||
|
|
|
@ -147,10 +147,13 @@
|
|||
|
||||
;; --- Settings ---------------------------
|
||||
|
||||
(def-setting! :-test-setting (x) x)
|
||||
|
||||
(def-test! set
|
||||
(should (assq :-test-setting doom-settings))
|
||||
(should (set! :-test-setting t))
|
||||
(let ((inhibit-message t))
|
||||
(should-not (set! :non-existant-setting (error "This shouldn't trigger")))))
|
||||
(eval-and-compile
|
||||
(let (doom-settings)
|
||||
(def-setting! :-test-setting (x) `(setq result ,x))
|
||||
(should (assq :-test-setting doom-settings))
|
||||
(let ((inhibit-message t)
|
||||
result)
|
||||
(set! :-test-setting t)
|
||||
(should result)
|
||||
(set! :non-existant-setting (error "This shouldn't trigger"))))))
|
||||
|
|
|
@ -1,15 +1,20 @@
|
|||
;; -*- no-byte-compile: t; -*-
|
||||
;;; ../core/test/core-projects.el
|
||||
|
||||
(projectile-mode +1)
|
||||
(require 'projectile)
|
||||
|
||||
;;
|
||||
;; `doom-project-p'
|
||||
(def-test! project-p
|
||||
:minor-mode projectile-mode
|
||||
(let ((default-directory doom-emacs-dir))
|
||||
(should (doom-project-p)))
|
||||
(let ((default-directory (expand-file-name "~")))
|
||||
(should-not (doom-project-p))))
|
||||
|
||||
;; `doom-project-p'
|
||||
(def-test! project-root
|
||||
:minor-mode projectile-mode
|
||||
;; Should resolve to project root
|
||||
(let ((default-directory doom-core-dir))
|
||||
(should (equal (doom-project-root) doom-emacs-dir)))
|
||||
|
@ -17,12 +22,16 @@
|
|||
(let ((default-directory (expand-file-name "~")))
|
||||
(should (equal (doom-project-root) default-directory))))
|
||||
|
||||
;; `doom-project-expand'
|
||||
(def-test! project-expand
|
||||
:minor-mode projectile-mode
|
||||
(let ((default-directory doom-core-dir))
|
||||
(should (equal (doom-project-expand "init.el")
|
||||
(expand-file-name "init.el" (doom-project-root))))))
|
||||
|
||||
;; `doom-project-has!'
|
||||
(def-test! project-has!
|
||||
:minor-mode projectile-mode
|
||||
(let ((default-directory doom-core-dir))
|
||||
;; Resolve from project root
|
||||
(should (doom-project-has! "init.el"))
|
||||
|
@ -32,4 +41,3 @@
|
|||
(should (doom-project-has! (and "init.el" (or "LICENSE" "does-not-exist"))))
|
||||
;; Should resolve relative paths from `default-directory'
|
||||
(should (doom-project-has! (and "./core.el" "../init.el")))))
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
;; -*- no-byte-compile: t; -*-
|
||||
;;; ../core/test/core-ui.el
|
||||
|
||||
(defmacro -with-temp-windows! (&rest body)
|
||||
(defmacro with-temp-windows!! (&rest body)
|
||||
(declare (indent defun))
|
||||
`(save-window-excursion
|
||||
`(progn
|
||||
(delete-other-windows)
|
||||
(cl-flet ((split-window (symbol-function #'split-window-horizontally)))
|
||||
(let ((a (get-buffer-create "a"))
|
||||
|
@ -17,15 +17,14 @@
|
|||
(let ((doom-major-mode-names '((text-mode . "abc")
|
||||
(lisp-mode . (lambda () "xyz"))
|
||||
(js-mode . t))))
|
||||
(with-temp-buffer
|
||||
(text-mode)
|
||||
(should (equal mode-name "abc"))
|
||||
(lisp-mode)
|
||||
(should (equal mode-name "xyz"))
|
||||
(should-error (js-mode)))))
|
||||
(text-mode)
|
||||
(should (equal mode-name "abc"))
|
||||
(lisp-mode)
|
||||
(should (equal mode-name "xyz"))
|
||||
(should-error (js-mode))))
|
||||
|
||||
(def-test! protect-visible-buffers
|
||||
(-with-temp-windows!
|
||||
(with-temp-windows!!
|
||||
(let ((kill-buffer-query-functions '(doom|protect-visible-buffers)))
|
||||
(switch-to-buffer a) (split-window)
|
||||
(switch-to-buffer b) (split-window)
|
||||
|
@ -35,7 +34,7 @@
|
|||
(should (kill-buffer)))))
|
||||
|
||||
(def-test! *quit-window
|
||||
(-with-temp-windows!
|
||||
(with-temp-windows!!
|
||||
(let (kill-buffer-query-functions)
|
||||
(switch-to-buffer a) (split-window)
|
||||
(switch-to-buffer b)
|
||||
|
|
|
@ -4,20 +4,21 @@
|
|||
(require! :completion company)
|
||||
(require 'company)
|
||||
|
||||
;;
|
||||
(def-test! set-company-backend
|
||||
(let ((default-backends (default-value 'company-backends)))
|
||||
:minor-mode company-mode
|
||||
(let ((company-backends '(default)))
|
||||
(set! :company-backend 'emacs-lisp-mode '(backend-1))
|
||||
(set! :company-backend 'lisp-interaction-mode 'backend-1 'backend-2)
|
||||
(set! :company-backend 'text-mode 'backend-1)
|
||||
(with-temp-buffer
|
||||
(emacs-lisp-mode)
|
||||
(should (equal (car company-backends) '(backend-1))))
|
||||
(should (equal company-backends '((backend-1) default))))
|
||||
(with-temp-buffer
|
||||
(lisp-interaction-mode)
|
||||
(should (equal company-backends
|
||||
(append '(backend-1 backend-2) default-backends))))
|
||||
(should (equal company-backends '(backend-1 backend-2 default))))
|
||||
(with-temp-buffer
|
||||
(text-mode)
|
||||
(should (eq (car company-backends) 'backend-1)))
|
||||
(should (equal company-backends '(backend-1 default))))
|
||||
;; global backends shouldn't be affected
|
||||
(should (equal company-backends default-backends))))
|
||||
(should (equal company-backends '(default)))))
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
;; -*- no-byte-compile: t; -*-
|
||||
;;; feature/evil/test/autoload-files.el
|
||||
|
||||
(defmacro -with-temp-files! (src dest &rest body)
|
||||
(defmacro with-temp-files!! (src dest &rest body)
|
||||
"Run FORMS in the context of a temporary package setup (as in, it won't
|
||||
affects your Emacs packages)."
|
||||
(declare (indent 2) (doc-string 3))
|
||||
|
@ -23,7 +23,7 @@ affects your Emacs packages)."
|
|||
;;
|
||||
(def-test! move-this-file
|
||||
":mv"
|
||||
(-with-temp-files! "/tmp/doom-buffer" "/tmp/doom-buffer-new"
|
||||
(with-temp-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))
|
||||
|
@ -31,7 +31,7 @@ affects your Emacs packages)."
|
|||
|
||||
(def-test! copy-this-file
|
||||
":cp"
|
||||
(-with-temp-files! "/tmp/doom-buffer-2" "/tmp/doom-buffer-2-new"
|
||||
(with-temp-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))
|
||||
|
@ -39,7 +39,7 @@ affects your Emacs packages)."
|
|||
|
||||
(def-test! delete-this-file
|
||||
":rm"
|
||||
(-with-temp-files! "/tmp/doom-buffer-3" nil
|
||||
(with-temp-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)))))
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
(require! :feature evil)
|
||||
|
||||
;;
|
||||
;; `evil-ex-replace-special-filenames'
|
||||
;; NOTE The majority of this function is tested in core/test/core-lib.el, this
|
||||
;; only tests the evil-mode-specific functionality.
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
(require! :feature workspaces)
|
||||
|
||||
(defmacro -with-workspace! (buffer-args &rest body)
|
||||
(defmacro with-workspace!! (buffer-args &rest body)
|
||||
(declare (indent defun))
|
||||
(let ((buffers
|
||||
(cl-loop for bsym in buffer-args
|
||||
|
@ -27,14 +27,19 @@
|
|||
|
||||
;;
|
||||
(def-test! init
|
||||
(-with-workspace! ()
|
||||
(with-workspace!! ()
|
||||
(should (equal (+workspace-current-name) +workspaces-main))))
|
||||
|
||||
(def-test! advice
|
||||
(should (advice-member-p #'+workspaces*auto-add-buffer #'switch-to-buffer)))
|
||||
(def-test! auto-add-buffer-to-persp
|
||||
(let ((a (generate-new-buffer "a")))
|
||||
(doom-set-buffer-real a t)
|
||||
(with-workspace!! ()
|
||||
(should-not (+workspace-contains-buffer-p a))
|
||||
(switch-to-buffer a)
|
||||
(should (+workspace-contains-buffer-p a)))))
|
||||
|
||||
(def-test! current
|
||||
(-with-workspace! ()
|
||||
(with-workspace!! ()
|
||||
(should (equal (+workspace-current-name) +workspaces-main))
|
||||
(should (+workspace-exists-p +workspaces-main))
|
||||
(let ((workspace (+workspace-get +workspaces-main))
|
||||
|
@ -45,7 +50,7 @@
|
|||
(should (equal workspace current-workspace)))))
|
||||
|
||||
(def-test! workspace-list
|
||||
(-with-workspace! ()
|
||||
(with-workspace!! ()
|
||||
(should (equal (+workspace-list-names)
|
||||
(list (+workspace-current-name))))
|
||||
(should (equal (+workspace-list)
|
||||
|
@ -53,7 +58,7 @@
|
|||
|
||||
(def-test! workspace-crud
|
||||
"Creating, reading, updating and deleting workspaces."
|
||||
(-with-workspace! ()
|
||||
(with-workspace!! ()
|
||||
(let ((new-workspace-name "*new-test*")
|
||||
(renamed-workspace-name "*old-test*"))
|
||||
(should (+workspace-new new-workspace-name))
|
||||
|
@ -67,14 +72,14 @@
|
|||
(should (= (length (+workspace-list-names)) 1)))))
|
||||
|
||||
(def-test! workspace-switch
|
||||
(-with-workspace! ()
|
||||
(with-workspace!! ()
|
||||
(let ((new-workspace-name "*new-test*"))
|
||||
(should-error (+workspace-switch new-workspace-name))
|
||||
(should (+workspace-switch new-workspace-name t))
|
||||
(should (equal (+workspace-current-name) new-workspace-name)))))
|
||||
|
||||
(def-test! buffer-list
|
||||
(-with-workspace! (a b)
|
||||
(with-workspace!! (a b)
|
||||
(let ((c (get-buffer-create "c"))
|
||||
(d (get-buffer-create "d")))
|
||||
(should (+workspace-contains-buffer-p a))
|
||||
|
|
|
@ -1,40 +1,40 @@
|
|||
;; -*- no-byte-compile: t; -*-
|
||||
;;; lang/org/test/autoload-org.el
|
||||
|
||||
(defmacro should-org-buffer! (source expected &rest body)
|
||||
(defmacro should-org-buffer!! (source expected &rest body)
|
||||
`(should-buffer! ,source ,expected
|
||||
(org-mode)
|
||||
,@body))
|
||||
|
||||
|
||||
;;
|
||||
;; `+org/insert-item'
|
||||
(def-test! insert-item-h1
|
||||
"Should append/prepend new first-level headers with an extra newline."
|
||||
(should-org-buffer! ("* {0}Header") ("* Header\n\n* {|}")
|
||||
(should-org-buffer!! ("* {0}Header") ("* Header\n\n* {|}")
|
||||
(+org/insert-item 'below))
|
||||
(should-org-buffer! ("* {0}Header") ("* {|}\n\n* Header")
|
||||
(should-org-buffer!! ("* {0}Header") ("* {|}\n\n* Header")
|
||||
(+org/insert-item 'above)))
|
||||
|
||||
(def-test! insert-item-h2
|
||||
"Should append/prepend new second-level (and higher) headers without an extra
|
||||
newline."
|
||||
(should-org-buffer! ("** {0}Header") ("** Header\n** {|}")
|
||||
(should-org-buffer!! ("** {0}Header") ("** Header\n** {|}")
|
||||
(+org/insert-item 'below))
|
||||
(should-org-buffer! ("** {0}Header") ("** {|}\n** Header")
|
||||
(should-org-buffer!! ("** {0}Header") ("** {|}\n** Header")
|
||||
(+org/insert-item 'above)))
|
||||
|
||||
(def-test! insert-item-plain-list
|
||||
"Should append/prepend new second-level (and higher) headers without an extra
|
||||
newline."
|
||||
(should-org-buffer! ("+ {0}List item") ("+ List item\n+ {|}")
|
||||
(should-org-buffer!! ("+ {0}List item") ("+ List item\n+ {|}")
|
||||
(+org/insert-item 'below))
|
||||
(should-org-buffer! ("+ {0}List item"
|
||||
(should-org-buffer!! ("+ {0}List item"
|
||||
" + Sub item")
|
||||
("+ List item"
|
||||
" + Sub item"
|
||||
"+ {|}")
|
||||
(+org/insert-item 'below))
|
||||
(should-org-buffer! ("+ {0}List item"
|
||||
(should-org-buffer!! ("+ {0}List item"
|
||||
"+ Next item")
|
||||
("+ List item"
|
||||
"+ {|}"
|
||||
|
|
|
@ -5,3 +5,5 @@
|
|||
(require! :lang org)
|
||||
|
||||
(require 'org (locate-library "org" nil doom--package-load-path))
|
||||
|
||||
;;
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
(load! ../autoload)
|
||||
|
||||
(defmacro -with-passwords! (buffer-args &rest body)
|
||||
(defmacro with-passwords!! (buffer-args &rest body)
|
||||
(declare (indent defun))
|
||||
`(cl-letf
|
||||
(((symbol-function '+pass--get-entry)
|
||||
|
@ -18,7 +18,7 @@
|
|||
|
||||
;;
|
||||
(def-test! get-field
|
||||
(-with-passwords!
|
||||
(with-passwords!!
|
||||
(should (equal (+pass-get-field "fake/source" "login")
|
||||
"HL2532-GANDI"))
|
||||
(should (equal (+pass-get-field "fake/source" "email")
|
||||
|
@ -29,14 +29,14 @@
|
|||
"henrik@lissner.net"))))
|
||||
|
||||
(def-test! missing-fields-return-nil
|
||||
(-with-passwords!
|
||||
(with-passwords!!
|
||||
(should-not (+pass-get-field "fake/source" '("x" "y" "z")))))
|
||||
|
||||
(def-test! missing-entries-throw-error
|
||||
(-with-passwords!
|
||||
(with-passwords!!
|
||||
(should-error (+pass-get-field "nonexistent/source" "login"))))
|
||||
|
||||
(def-test! get-login
|
||||
(-with-passwords!
|
||||
(with-passwords!!
|
||||
(should (equal (+pass-get-user "fake/source") "HL2532-GANDI"))
|
||||
(should (equal (+pass-get-secret "fake/source") "defuse-account-gad"))))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue