Skip to content

Commit

Permalink
validate if hook is a function, not a symbol
Browse files Browse the repository at this point in the history
  • Loading branch information
tralph3 committed Jul 7, 2024
1 parent 77f996a commit 583d828
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions conner-tests.el
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,12 @@
(should-error (conner--validate-command-plist '(:name "name" :command "test" :type "invalidtype")))
(should-error (conner--validate-command-plist '(:name "name" :command "test" :type "compile" :workdir notstring)))
(should-error (conner--validate-command-plist '(:name "name" :command "test" :type "compile" :environment notlist)))
(should-error (conner--validate-command-plist '(:name "name" :command "test" :type "compile" :hook "not a symbol!")))
(should-error (conner--validate-command-plist '(:name "name" :command "test" :type "compile" :hook "not a function!")))
(should-error (conner--validate-command-plist '(:name "name" :command "test" :type "compile" :silent "not a boolean")))
(should (eq (conner--validate-command-plist '(:name "name" :command symbol :type "compile")) nil))
(should (eq (conner--validate-command-plist '(:name "name" :command "test" :type "compile")) nil))))
(should (eq (conner--validate-command-plist '(:name "name" :command "test" :type "compile")) nil))
(should (eq (conner--validate-command-plist '(:name "name" :command "hook symbol" :type "compile" :hook car)) nil))
(should (eq (conner--validate-command-plist '(:name "name" :command "hook lambda" :type "compile" :hook (lambda () t))) nil))))

(ert-deftest conner-test-hooks ()
(with-temp-env
Expand Down
4 changes: 2 additions & 2 deletions conner.el
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,9 @@ If Projectile is available, it defaults to it. Otherwise, it uses
(when (not (or (listp (plist-get plist :environment))
(not (plist-get plist :environment))))
(user-error "Environment is not a list"))
(when (not (or (symbolp (plist-get plist :hook))
(when (not (or (functionp (plist-get plist :hook))
(not (plist-get plist :hook))))
(user-error "Hook is not a symbol"))
(user-error "Hook is not a function"))
(when (not (booleanp (plist-get plist :silent)))
(user-error "Silent is not a boolean"))))

Expand Down

0 comments on commit 583d828

Please sign in to comment.