Reorganize unit-tests and test workflow
+ Moved unit tests out of tests/ and into their respective modules. + Rewrite makefile and added these tasks: + <MODULE>/<SUBMODULE> -- byte-compile a specific module + test:<MODULE>/<SUBMODULE> -- runs tests for a specific module + testi -- run tests in an interactive session of Emacs (WIP) + run -- opens an Emacs session with this config; useful when it is in a non-standard location.
This commit is contained in:
parent
cacd188286
commit
9c93c453e8
22 changed files with 511 additions and 423 deletions
35
modules/tools/password-store/test/autoload-pass.el
Normal file
35
modules/tools/password-store/test/autoload-pass.el
Normal file
|
@ -0,0 +1,35 @@
|
|||
;; -*- no-byte-compile: t; -*-
|
||||
;;; tools/password-store/test/autoload-pass.el
|
||||
|
||||
(defmacro -with-passwords! (buffer-args &rest body)
|
||||
(declare (indent defun))
|
||||
`(cl-letf
|
||||
(((symbol-function 'auth-pass-parse-entry)
|
||||
(lambda (entry)
|
||||
(when (equal entry "fake/source")
|
||||
'((secret . "defuse-account-gad")
|
||||
("login" . "HL2532-GANDI")
|
||||
("alt-login" . "hlissner")
|
||||
("email" . "henrik@lissner.net")
|
||||
("url" . "https://www.gandi.net/login"))))))
|
||||
,@body))
|
||||
|
||||
;;
|
||||
(def-test! get-field
|
||||
(-with-passwords!
|
||||
(should (equal (+pass-get-field "fake/source" "login")
|
||||
"HL2532-GANDI"))
|
||||
(should (equal (+pass-get-field "fake/source" "email")
|
||||
"henrik@lissner.net"))
|
||||
(should (equal (+pass-get-field "fake/source" '("alt-login" "email"))
|
||||
"hlissner"))
|
||||
(should (equal (+pass-get-field "fake/source" '("username" "email"))
|
||||
"henrik@lissner.net"))
|
||||
(should-not (+pass-get-field "fake/source" '("x" "y" "z")))
|
||||
|
||||
(should-error (+pass-get-field "nonexistent/source" "login"))))
|
||||
|
||||
(def-test! get-login
|
||||
(-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