Refactor and fix unit tests, plus isolate them better

This commit is contained in:
Henrik Lissner 2017-12-31 11:45:02 -05:00
parent 5c74814860
commit 8ad2666f8f
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
14 changed files with 146 additions and 117 deletions

View file

@ -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"))))