1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-11-24 07:20:37 +00:00

Use slot names rather than their :initargs

* test/lisp/emacs-lisp/eieio-tests/eieio-tests.el
(eieio-test-39-clone-instance-inheritor-with-args):

* test/lisp/auth-source-tests.el (auth-source-ensure-ignored-backend)
(auth-source-backend-parse-macos-keychain)
(auth-source-backend-parse-macos-keychain-generic-string)
(auth-source-backend-parse-macos-keychain-internet-string)
(auth-source-backend-parse-macos-keychain-internet-symbol)
(auth-source-backend-parse-macos-keychain-generic-symbol)
(auth-source-backend-parse-macos-keychain-internet-default-string)
(auth-source-backend-parse-plstore, auth-source-backend-parse-netrc)
(auth-source-backend-parse-netrc-string)
(auth-source-backend-parse-secrets)
(auth-source-backend-parse-secrets-strings)
(auth-source-backend-parse-secrets-alias)
(auth-source-backend-parse-secrets-symbol)
(auth-source-backend-parse-secrets-no-alias):
Use slot names rather than their :initargs.
This commit is contained in:
Stefan Monnier 2024-02-07 11:11:38 -05:00
parent ef3fed1a48
commit b068725d40
2 changed files with 95 additions and 72 deletions

View File

@ -33,8 +33,8 @@
(require 'secrets)
(defun auth-source-ensure-ignored-backend (source)
(auth-source-validate-backend source '((:source . "")
(:type . ignore))))
(auth-source-validate-backend source '((source . "")
(type . ignore))))
(defun auth-source-validate-backend (source validation-alist)
(let ((backend (auth-source-backend-parse source)))
@ -44,84 +44,101 @@
(ert-deftest auth-source-backend-parse-macos-keychain ()
(auth-source-validate-backend '(:source (:macos-keychain-generic foobar))
'((:source . "foobar")
(:type . macos-keychain-generic)
(:search-function . auth-source-macos-keychain-search)
(:create-function . auth-source-macos-keychain-create))))
'((source . "foobar")
(type . macos-keychain-generic)
(search-function . auth-source-macos-keychain-search)
(create-function . auth-source-macos-keychain-create))))
(ert-deftest auth-source-backend-parse-macos-keychain-generic-string ()
(auth-source-validate-backend "macos-keychain-generic:foobar"
'((:source . "foobar")
(:type . macos-keychain-generic)
(:search-function . auth-source-macos-keychain-search)
(:create-function . auth-source-macos-keychain-create))))
'((source . "foobar")
(type . macos-keychain-generic)
(search-function
. auth-source-macos-keychain-search)
(create-function
. auth-source-macos-keychain-create))))
(ert-deftest auth-source-backend-parse-macos-keychain-internet-string ()
(auth-source-validate-backend "macos-keychain-internet:foobar"
'((:source . "foobar")
(:type . macos-keychain-internet)
(:search-function . auth-source-macos-keychain-search)
(:create-function . auth-source-macos-keychain-create))))
'((source . "foobar")
(type . macos-keychain-internet)
(search-function
. auth-source-macos-keychain-search)
(create-function
. auth-source-macos-keychain-create))))
(ert-deftest auth-source-backend-parse-macos-keychain-internet-symbol ()
(auth-source-validate-backend 'macos-keychain-internet
'((:source . "default")
(:type . macos-keychain-internet)
(:search-function . auth-source-macos-keychain-search)
(:create-function . auth-source-macos-keychain-create))))
'((source . "default")
(type . macos-keychain-internet)
(search-function
. auth-source-macos-keychain-search)
(create-function
. auth-source-macos-keychain-create))))
(ert-deftest auth-source-backend-parse-macos-keychain-generic-symbol ()
(auth-source-validate-backend 'macos-keychain-generic
'((:source . "default")
(:type . macos-keychain-generic)
(:search-function . auth-source-macos-keychain-search)
(:create-function . auth-source-macos-keychain-create))))
'((source . "default")
(type . macos-keychain-generic)
(search-function
. auth-source-macos-keychain-search)
(create-function
. auth-source-macos-keychain-create))))
(ert-deftest auth-source-backend-parse-macos-keychain-internet-default-string ()
(auth-source-validate-backend 'macos-keychain-internet
'((:source . "default")
(:type . macos-keychain-internet)
(:search-function . auth-source-macos-keychain-search)
(:create-function . auth-source-macos-keychain-create))))
'((source . "default")
(type . macos-keychain-internet)
(search-function
. auth-source-macos-keychain-search)
(create-function
. auth-source-macos-keychain-create))))
(ert-deftest auth-source-backend-parse-plstore ()
(auth-source-validate-backend '(:source "foo.plist")
'((:source . "foo.plist")
(:type . plstore)
(:search-function . auth-source-plstore-search)
(:create-function . auth-source-plstore-create))))
'((source . "foo.plist")
(type . plstore)
(search-function . auth-source-plstore-search)
(create-function
. auth-source-plstore-create))))
(ert-deftest auth-source-backend-parse-netrc ()
(auth-source-validate-backend '(:source "foo")
'((:source . "foo")
(:type . netrc)
(:search-function . auth-source-netrc-search)
(:create-function . auth-source-netrc-create))))
'((source . "foo")
(type . netrc)
(search-function . auth-source-netrc-search)
(create-function
. auth-source-netrc-create))))
(ert-deftest auth-source-backend-parse-netrc-string ()
(auth-source-validate-backend "foo"
'((:source . "foo")
(:type . netrc)
(:search-function . auth-source-netrc-search)
(:create-function . auth-source-netrc-create))))
'((source . "foo")
(type . netrc)
(search-function . auth-source-netrc-search)
(create-function
. auth-source-netrc-create))))
(ert-deftest auth-source-backend-parse-secrets ()
(provide 'secrets) ; simulates the presence of the `secrets' package
(let ((secrets-enabled t))
(auth-source-validate-backend '(:source (:secrets "foo"))
'((:source . "foo")
(:type . secrets)
(:search-function . auth-source-secrets-search)
(:create-function . auth-source-secrets-create)))))
'((source . "foo")
(type . secrets)
(search-function
. auth-source-secrets-search)
(create-function
. auth-source-secrets-create)))))
(ert-deftest auth-source-backend-parse-secrets-strings ()
(provide 'secrets) ; simulates the presence of the `secrets' package
(let ((secrets-enabled t))
(auth-source-validate-backend "secrets:foo"
'((:source . "foo")
(:type . secrets)
(:search-function . auth-source-secrets-search)
(:create-function . auth-source-secrets-create)))))
'((source . "foo")
(type . secrets)
(search-function
. auth-source-secrets-search)
(create-function
. auth-source-secrets-create)))))
(ert-deftest auth-source-backend-parse-secrets-alias ()
(provide 'secrets) ; simulates the presence of the `secrets' package
@ -129,10 +146,12 @@
;; Redefine `secrets-get-alias' to map 'foo to "foo"
(cl-letf (((symbol-function 'secrets-get-alias) (lambda (_) "foo")))
(auth-source-validate-backend '(:source (:secrets foo))
'((:source . "foo")
(:type . secrets)
(:search-function . auth-source-secrets-search)
(:create-function . auth-source-secrets-create))))))
'((source . "foo")
(type . secrets)
(search-function
. auth-source-secrets-search)
(create-function
. auth-source-secrets-create))))))
(ert-deftest auth-source-backend-parse-secrets-symbol ()
(provide 'secrets) ; simulates the presence of the `secrets' package
@ -140,10 +159,12 @@
;; Redefine `secrets-get-alias' to map 'default to "foo"
(cl-letf (((symbol-function 'secrets-get-alias) (lambda (_) "foo")))
(auth-source-validate-backend 'default
'((:source . "foo")
(:type . secrets)
(:search-function . auth-source-secrets-search)
(:create-function . auth-source-secrets-create))))))
'((source . "foo")
(type . secrets)
(search-function
. auth-source-secrets-search)
(create-function
. auth-source-secrets-create))))))
(ert-deftest auth-source-backend-parse-secrets-no-alias ()
(provide 'secrets) ; simulates the presence of the `secrets' package
@ -152,10 +173,12 @@
;; "Login" is used by default
(cl-letf (((symbol-function 'secrets-get-alias) (lambda (_) nil)))
(auth-source-validate-backend '(:source (:secrets foo))
'((:source . "Login")
(:type . secrets)
(:search-function . auth-source-secrets-search)
(:create-function . auth-source-secrets-create))))))
'((source . "Login")
(type . secrets)
(search-function
. auth-source-secrets-search)
(create-function
. auth-source-secrets-create))))))
(ert-deftest auth-source-backend-parse-invalid-or-nil-source ()
(provide 'secrets) ; simulates the presence of the `secrets' package

View File

@ -1011,24 +1011,24 @@ Subclasses to override slot attributes."))
(B (clone A :b "bb"))
(C (clone B :a "aa")))
(should (string= "aa" (oref C :a)))
(should (string= "bb" (oref C :b)))
(should (string= "aa" (oref C a)))
(should (string= "bb" (oref C b)))
(should (slot-boundp A :a))
(should-not (slot-boundp A :b))
(should-not (slot-boundp A :c))
(should (slot-boundp A 'a))
(should-not (slot-boundp A 'b))
(should-not (slot-boundp A 'c))
(should-not (slot-boundp B :a))
(should (slot-boundp B :b))
(should-not (slot-boundp A :c))
(should-not (slot-boundp B 'a))
(should (slot-boundp B 'b))
(should-not (slot-boundp A 'c))
(should (slot-boundp C :a))
(should-not (slot-boundp C :b))
(should-not (slot-boundp C :c))
(should (slot-boundp C 'a))
(should-not (slot-boundp C 'b))
(should-not (slot-boundp C 'c))
(should (eieio-instance-inheritor-slot-boundp C :a))
(should (eieio-instance-inheritor-slot-boundp C :b))
(should-not (eieio-instance-inheritor-slot-boundp C :c))))
(should (eieio-instance-inheritor-slot-boundp C 'a))
(should (eieio-instance-inheritor-slot-boundp C 'b))
(should-not (eieio-instance-inheritor-slot-boundp C 'c))))
;;;; Interaction with defstruct