-
Notifications
You must be signed in to change notification settings - Fork 456
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for el-get-compute-new-status
- Loading branch information
Showing
1 changed file
with
112 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,16 @@ | |
(defmacro* ert-deftest (name () &body docstring-keys-and-body) | ||
(message "Skipping tests, ERT is not available")))) | ||
|
||
(defun el-get-plist-equal (plist1 plist2) | ||
(let ((keys (el-get-plist-keys plist1))) | ||
(and (equal (sort keys #'string<) | ||
(sort (el-get-plist-keys plist2) #'string<)) | ||
(loop for key in keys | ||
unless (equal (plist-get plist1 key) | ||
(plist-get plist2 key)) | ||
return nil | ||
finally return t)))) | ||
|
||
(defvar el-get-test-output-buffer nil) | ||
(when noninteractive | ||
(defadvice message (around el-get-test-catch-output activate) | ||
|
@@ -232,3 +242,105 @@ [email protected]")) | |
(lambda (package url) | ||
(error "Leave 'el-get-insecure-check to git")))) | ||
(should (el-get-do-update "dummy"))))) | ||
|
||
(defun el-get-test-compute-new-status-equal (status1 status2) | ||
"Check equality for `el-get-compute-new-status' results." | ||
(and (el-get-plist-equal (nth 0 status1) (nth 0 status2)) | ||
(equal (nth 1 status1) (nth 1 status2)) | ||
(el-get-plist-equal (nth 2 status1) (nth 2 status2)) | ||
(el-get-plist-equal (nth 3 status1) (nth 3 status2)))) | ||
|
||
(ert-deftest el-get-test-compute-new-status () | ||
"Test `el-get-compute-new-status'." | ||
(let* ((old '(:name a | ||
:type git | ||
:load-path "load-old" | ||
:depends (depends old) | ||
:build (("build" "old")) | ||
:build/gnu-linux (("build/gnu-linux" "old")) | ||
:url "http://example.com/url/old")) | ||
(new '(:name a | ||
:type git | ||
:load-path "load-new" | ||
:depends (depends new) | ||
:build (("build" "new")) | ||
:build/gnu-linux (("build/gnu-linux" "new")) | ||
:url "http://example.com/url/new")) | ||
(expected '((:name a | ||
:type git | ||
:load-path "load-new" | ||
:depends (depends old) | ||
:build (("build" "old")) | ||
:build/gnu-linux (("build/gnu-linux" "old")) | ||
:url "http://example.com/url/old") | ||
(reinstall) | ||
(:depends (depends new) | ||
:build (("build new")) | ||
:build/gnu-linux (("build/gnu-linux" "new")) | ||
:url "http://example.com/url/new") | ||
(:depends (depends old) | ||
:build (("build old")) | ||
:build/gnu-linux (("build/gnu-linux" "old")) | ||
:url "http://example.com/url/old"))) | ||
(update-expected '((:name a | ||
:type git | ||
:load-path "load-new" | ||
:depends (depends new) | ||
:build (("build" "new")) | ||
:build/gnu-linux (("build/gnu-linux" "new")) | ||
:url "http://example.com/url/old") | ||
(reinstall) | ||
(:url "http://example.com/url/new") | ||
(:url "http://example.com/url/old")))) | ||
(should (el-get-test-compute-new-status-equal | ||
(el-get-compute-new-status 'init old new) | ||
expected)) | ||
(should (el-get-test-compute-new-status-equal | ||
(el-get-compute-new-status 'update old new) | ||
update-expected)) | ||
(should (el-get-test-compute-new-status-equal | ||
(el-get-compute-new-status 'reinstall old new) | ||
(list new nil nil nil))))) | ||
|
||
(ert-deftest el-get-test-compute-new-status-2 () | ||
"Test `el-get-compute-new-status'." | ||
(let* ((old '(:name a | ||
:type git | ||
:load-path "load-old" | ||
:depends (depends old) | ||
:build (("build" "old")) | ||
:build/gnu-linux (("build/gnu-linux" "old")) | ||
:url "http://example.com/url/old")) | ||
(new '(:name a | ||
:type git | ||
:load-path "load-new" | ||
:depends (depends new) | ||
:build (("build" "new")) | ||
:build/gnu-linux (("build/gnu-linux" "new")) | ||
:url "http://example.com/url/old")) | ||
(init-result (el-get-compute-new-status 'init old new)) | ||
(init-expected '((:name a | ||
:type git | ||
:load-path "load-new" | ||
:depends (depends old) | ||
:build (("build" "old")) | ||
:build/gnu-linux (("build/gnu-linux" "old")) | ||
:url "http://example.com/url/old") | ||
(update reinstall) | ||
(:depends (depends new) | ||
:build (("build new")) | ||
:build/gnu-linux (("build/gnu-linux" "new"))) | ||
(:depends (depends old) | ||
:build (("build old")) | ||
:build/gnu-linux (("build/gnu-linux" "old"))))) | ||
(update-result (el-get-compute-new-status 'update old new)) | ||
(update-expected '((:name a | ||
:type git | ||
:load-path "load-new" | ||
:depends (depends new) | ||
:build (("build" "new")) | ||
:build/gnu-linux (("build/gnu-linux" "new")) | ||
:url "http://example.com/url/old") | ||
nil nil nil))) | ||
(should (el-get-test-compute-new-status-equal init-result init-expected)) | ||
(should (el-get-test-compute-new-status-equal update-result update-expected)))) |