[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: RFC: feature/auth-source-pass branch integrating auth-source with th
From: |
Noam Postavsky |
Subject: |
Re: RFC: feature/auth-source-pass branch integrating auth-source with the pass secret manager |
Date: |
Tue, 28 Mar 2017 16:26:30 -0400 |
On Mon, Mar 27, 2017 at 1:45 PM, Ted Zlatanov <address@hidden> wrote:
> Please comment on the code, if you have any questions or concerns.
+(defun auth-source-pass--remove-directory-name (name)
+ "Remove directories from NAME.
+E.g., if NAME is \"foo/bar\", return \"bar\"."
+ (replace-regexp-in-string ".*/" "" name))
This could be replaced with `file-name-nondirectory', I think.
+(defun auth-source-pass--should-have-message-containing (regexp)
+ "Assert that at least one `auth-source-do-debug` matched REGEXP."
+ (should (seq-find (lambda (message)
+ (string-match regexp message))
+ auth-source-pass--debug-log)))
The reliance on debug prints for the tests seems a bit strange to me
(I don't really have a better suggestion though).
+(defmacro auth-source-pass--deftest (name arglist store &rest body)
+ "Define a new ert-test NAME with ARGLIST using STORE as password-store.
+BODY is a sequence of instructions that will be evaluated.
+
+This macro overrides `auth-source-pass-parse-entry' and
`auth-source-pass-entries' to
+test code without touching the file system."
I would suggest rather defining auth-source-pass--with-store, and
leaving the test defining part to ert-deftest.
So that, e.g.,
(auth-source-pass--deftest auth-source-pass-find-match-matching-at-entry-name ()
'(("foo"))
(should (equal (auth-source-pass--find-match "foo" nil)
"foo")))
becomes
(ert-deftest auth-source-pass-find-match-matching-at-entry-name ()
(auth-source-pass--with-store '(("foo"))
(should (equal (auth-source-pass--find-match "foo" nil)
"foo"))))