Skip to content

Commit

Permalink
feat(test): add tests that run outside of a Git repo
Browse files Browse the repository at this point in the history
  • Loading branch information
gekoke committed May 20, 2024
1 parent fc7c551 commit 3345811
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 19 deletions.
5 changes: 3 additions & 2 deletions nix/packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,20 @@ _: {
packageRequires = [
pkgs.emacsPackages.el-patch
pkgs.emacsPackages.nerd-icons
pkgs.emacsPackages.magit
];

doCheck = true;

nativeCheckInputs = [
pkgs.git
pkgs.emacs
pkgs.emacsPackages.magit
] ++ packageRequires;

checkPhase = ''
git init # need to be in repository for Magit tests to not fail
emacs --batch -l ert -l magit-file-icons.el -l ./test/magit-file-icons-tests.el -f ert-run-tests-batch-and-exit
git init
emacs --batch -l ert -l magit-file-icons.el -l ./test/magit-file-icons-git-repo-tests.el -f ert-run-tests-batch-and-exit
'';

meta = {
Expand Down
29 changes: 29 additions & 0 deletions test/magit-file-icons-git-repo-tests.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
;; -*- lexical-binding: t; -*-

(require 'ert)
(require 'el-patch)
(require 'magit-file-icons)

(ert-deftest magit-file-icons-test-can-open-magit-status-buffer-while-in-minor-mode ()
(magit-file-icons-mode +1)
(magit-status-setup-buffer))

(ert-deftest magit-file-icons-test-can-enable-minor-mode-in-magit-status-buffer ()
(magit-status-setup-buffer)
(magit-file-icons-mode +1))

(ert-deftest magit-file-icons-test-can-disable-minor-mode-in-magit-status-buffer ()
(magit-file-icons-mode +1)
(magit-status-setup-buffer)
(magit-file-icons-mode -1))

(ert-deftest magit-file-icons-test-can-toggle-minor-mode-in-magit-status-buffer ()
(magit-file-icons-mode +1)
(magit-status-setup-buffer)
(magit-file-icons-mode 'toggle)
(magit-file-icons-mode 'toggle))

;; Local Variables:
;; flycheck-disabled-checkers: (emacs-lisp-checkdoc)
;; End:

18 changes: 1 addition & 17 deletions test/magit-file-icons-tests.el
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,9 @@
(ert-deftest magit-file-icons-test-has-no-invalid-templates ()
(el-patch-validate-all-templates))

(ert-deftest magit-file-icons-test-can-open-magit-status-buffer-while-in-minor-mode ()
(magit-file-icons-mode +1)
(magit-status-setup-buffer))

(ert-deftest magit-file-icons-test-can-enable-minor-mode-in-magit-status-buffer ()
(magit-status-setup-buffer)
(ert-deftest magit-file-icons-test-can-load-minor-mode-outside-of-git-repo ()
(magit-file-icons-mode +1))

(ert-deftest magit-file-icons-test-can-disable-minor-mode-in-magit-status-buffer ()
(magit-file-icons-mode +1)
(magit-status-setup-buffer)
(magit-file-icons-mode -1))

(ert-deftest magit-file-icons-test-can-toggle-minor-mode-in-magit-status-buffer ()
(magit-file-icons-mode +1)
(magit-status-setup-buffer)
(magit-file-icons-mode 'toggle)
(magit-file-icons-mode 'toggle))

;; Local Variables:
;; flycheck-disabled-checkers: (emacs-lisp-checkdoc)
;; End:
Expand Down

0 comments on commit 3345811

Please sign in to comment.