aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/test-dirvish-config-playlist.el15
-rw-r--r--tests/test-dirvish-config-wrappers.el6
2 files changed, 21 insertions, 0 deletions
diff --git a/tests/test-dirvish-config-playlist.el b/tests/test-dirvish-config-playlist.el
index 3876a177..d059a899 100644
--- a/tests/test-dirvish-config-playlist.el
+++ b/tests/test-dirvish-config-playlist.el
@@ -78,5 +78,20 @@ lowercase extension list."
"Boundary: a name that's just `.m3u' becomes empty after stripping."
(should (equal (cj/--playlist-sanitize-name ".m3u") "")))
+;;; cj/--playlist-name-safe-p
+
+(ert-deftest test-cj--playlist-name-safe-p-bare-name ()
+ "Normal: a bare filename is safe."
+ (should (cj/--playlist-name-safe-p "roadtrip")))
+
+(ert-deftest test-cj--playlist-name-safe-p-empty ()
+ "Boundary: an empty name is not safe."
+ (should-not (cj/--playlist-name-safe-p "")))
+
+(ert-deftest test-cj--playlist-name-safe-p-rejects-separators ()
+ "Error: any directory separator (relative, absolute, or nested) is rejected."
+ (dolist (bad '("../evil" "../../etc/cron" "/etc/passwd" "sub/dir/name"))
+ (should-not (cj/--playlist-name-safe-p bad))))
+
(provide 'test-dirvish-config-playlist)
;;; test-dirvish-config-playlist.el ends here
diff --git a/tests/test-dirvish-config-wrappers.el b/tests/test-dirvish-config-wrappers.el
index 7072fcf7..bead4583 100644
--- a/tests/test-dirvish-config-wrappers.el
+++ b/tests/test-dirvish-config-wrappers.el
@@ -140,5 +140,11 @@ calls the wallpaper-setter binary."
(should (member "/some/picture.jpg" call-process-args))
(should (string-match-p "Wallpaper set" msg))))
+(ert-deftest test-dirvish-set-wallpaper-no-file-errors ()
+ "Error: with no file at point, set-wallpaper signals user-error rather
+than passing nil to expand-file-name."
+ (cl-letf (((symbol-function 'dired-file-name-at-point) (lambda () nil)))
+ (should-error (cj/set-wallpaper) :type 'user-error)))
+
(provide 'test-dirvish-config-wrappers)
;;; test-dirvish-config-wrappers.el ends here