aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
author813gan <29867887+813gan@users.noreply.github.com>2022-10-30 16:10:19 +0100
committerGitHub <noreply@github.com>2022-10-30 17:10:19 +0200
commit20e4444dea4baeba332c39ab3c401d9209c62e43 (patch)
tree64e2beda310cd2a0e52d4dd0364ed8d253b6c376 /test
parent95134e1ba2f9f1b7a21ccc2c565ffc39cbfcd2f6 (diff)
Add helpers for dir-local-variables for 3rd party use (#1737)
Functions `projectile-add-dir-local-variable` and `projectile-delete-dir-local-variable` wraps their built-in counterparts. They always use `.dir-locals.el` from root of projectile project.
Diffstat (limited to 'test')
-rw-r--r--test/projectile-test.el44
1 files changed, 44 insertions, 0 deletions
diff --git a/test/projectile-test.el b/test/projectile-test.el
index 875b01e..f277af1 100644
--- a/test/projectile-test.el
+++ b/test/projectile-test.el
@@ -990,6 +990,50 @@ Just delegates OPERATION and ARGS for all operations except for`shell-command`'.
(let ((projectile-known-projects nil))
(expect (projectile-switch-project) :to-throw))))
+(describe "projectile-delete-dir-local-variable"
+ (it "Deletes existing dir-local variables"
+ (projectile-test-with-sandbox
+ (projectile-test-with-files
+ ("project/"
+ "project/.dir-locals.el"
+ "project/.projectile")
+ (append-to-file
+ "((nil . ((foo . bar))))" nil "project/.dir-locals.el")
+ (with-current-buffer (find-file-noselect "project/.projectile" t)
+ (let ((enable-local-variables :all))
+ (hack-dir-local-variables-non-file-buffer)
+ (expect (boundp 'foo) :to-be 't)
+
+ (projectile-delete-dir-local-variable nil 'foo)
+ (expect (boundp 'foo) :to-be nil) ))))))
+
+(describe "projectile-add-dir-local-variable"
+ (it "Adds new dir-local variables"
+ (projectile-test-with-sandbox
+ (projectile-test-with-files
+ ("project/"
+ "project/.projectile")
+ (with-current-buffer (find-file-noselect "project/.projectile" t)
+ (let ((enable-local-variables :all))
+ (expect (boundp 'fooo) :to-be nil)
+
+ (projectile-add-dir-local-variable nil 'fooo 1)
+ (hack-dir-local-variables-non-file-buffer)
+ (expect (boundp 'fooo) :to-be 't)
+ (expect fooo :to-be 1) ))))))
+
+(describe "projectile-add-dir-local-variable"
+ (it "Fails when there is no projectile project"
+ (projectile-test-with-sandbox
+ (let ((default-directory "/"))
+ (expect (projectile-add-dir-local-variable nil 'fooo 1) :to-throw 'error)) )))
+
+(describe "projectile-delete-dir-local-variable"
+ (it "Fails when there is no projectile project"
+ (projectile-test-with-sandbox
+ (let ((default-directory "/"))
+ (expect (projectile-delete-dir-local-variable nil 'fooo 1) :to-throw 'error)) )))
+
(describe "projectile-switch-project-by-name"
(it "calls the switch project action with project-to-switch's dir-locals loaded"
(defvar switch-project-foo)