[core] Add "unit" and functional tests for archvie verification

This commit is contained in:
syl20bnr 2019-08-24 22:49:48 -04:00
parent cfb12e9bd5
commit 09af9fc40b
5 changed files with 85 additions and 1 deletions

View File

@ -46,5 +46,48 @@
(should (eq 'spacemacs-base (third configuration-layer--used-layers)))))
;; ---------------------------------------------------------------------------
;; Lazy installation of layers
;; configuration-layer//stable-elpa-verify-archive
;; ---------------------------------------------------------------------------
(ert-deftest test-stable-elpa-verify-archive--verification-ok ()
(cl-letf (((symbol-function 'configuration-layer//stable-elpa-tarball-local-file)
(lambda ()
(concat spacemacs-test-directory
"core/data/signed-test-stable-elpa.tar.gz")))
((symbol-function 'configuration-layer//stable-elpa-tarball-local-sign-file)
(lambda ()
(concat spacemacs-test-directory
"core/data/signed-test-stable-elpa.tar.gz.sig")))
((symbol-function 'configuration-layer//stable-elpa-ask-to-continue)
(lambda (x)
(message "Verification Error: %s" x)
nil))
((symbol-function 'configuration-layer//error)
(lambda (x)
(message "Fatal Error: %s" x)
nil))
((symbol-function 'message) 'ignore))
(should (equal t (configuration-layer//stable-elpa-verify-archive)))))
(ert-deftest test-stable-elpa-verify-archive--verification-failed ()
(let (verification-error)
(cl-letf (((symbol-function 'configuration-layer//stable-elpa-tarball-local-file)
(lambda ()
(concat spacemacs-test-directory
"core/data/test-stable-elpa.tar.gz")))
((symbol-function 'configuration-layer//stable-elpa-tarball-local-sign-file)
(lambda ()
(concat spacemacs-test-directory
"core/data/signed-test-stable-elpa.tar.gz.sig")))
((symbol-function 'configuration-layer//stable-elpa-ask-to-continue)
(lambda (x)
(setq verification-error x)
nil))
((symbol-function 'configuration-layer//error)
(lambda (x)
(message "Fatal Error: %s" x)
nil))
((symbol-function 'message) 'ignore))
(should (and (null (configuration-layer//stable-elpa-verify-archive))
(string-match-p "^Verification failed!.*"
verification-error))))))

View File

@ -3016,3 +3016,44 @@
:reqs '((foo 7)))))
(let ((patched-pkg (configuration-layer//package-install-org 'identity pkg)))
(should (equal pkg patched-pkg)))))
;; ---------------------------------------------------------------------------
;; configuration-layer//stable-elpa-verify-archive
;; ---------------------------------------------------------------------------
(ert-deftest test-stable-elpa-verify-archive--archive-not-found-is-fatal-error ()
(mocker-let
((configuration-layer//stable-elpa-tarball-local-file
nil ((:record-cls 'mocker-stub-record
:output
(concat spacemacs-test-directory
"core/data/not-found.tar.gz")
:occur 1)))
(configuration-layer//stable-elpa-tarball-local-sign-file
nil ((:record-cls 'mocker-stub-record
:output
(concat spacemacs-test-directory
"core/data/stable-elpa.sig")
:occur 1)))
(configuration-layer//error
(msg &rest args) ((:record-cls 'mocker-stub-record :occur 1))))
(should (null (configuration-layer//stable-elpa-verify-archive)))))
(ert-deftest test-stable-elpa-verify-archive--signature-not-found-is-fatal-error ()
(mocker-let
((configuration-layer//stable-elpa-tarball-local-file
nil ((:record-cls 'mocker-stub-record
:output
(concat spacemacs-test-directory
"core/data/signed-stable-elpa.tar.gz")
:occur 1)))
(configuration-layer//stable-elpa-tarball-local-sign-file
nil ((:record-cls 'mocker-stub-record
:output
(concat spacemacs-test-directory
"core/data/not-found.sig")
:occur 1)))
(configuration-layer//error
(msg &rest args) ((:record-cls 'mocker-stub-record :occur 1))))
(should (null (configuration-layer//stable-elpa-verify-archive)))))

Binary file not shown.

Binary file not shown.

Binary file not shown.