aboutsummaryrefslogtreecommitdiff
path: root/tests/test-dwim-shell-config-command-fixes.el
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-06-13 13:51:56 -0500
committerCraig Jennings <c@cjennings.net>2026-06-13 13:51:56 -0500
commit6d4461fc3264d6a730d32f1f8a5b58f78769a840 (patch)
tree65ae9d4a372594d41e1c494383bbfc5f75aacc78 /tests/test-dwim-shell-config-command-fixes.el
parent0c024848f91a9ca1aad8e4a0bd651091feb3608a (diff)
downloaddotemacs-6d4461fc3264d6a730d32f1f8a5b58f78769a840.tar.gz
dotemacs-6d4461fc3264d6a730d32f1f8a5b58f78769a840.zip
fix(dwim-shell): valid zip name, real backup timestamp, reachable menu key
Three audit fixes. Single-file zip named the archive after the input file (<<fne>>.<<e>>), making invalid archives and a "foo." name for directories. It now builds <fne>.zip. The dated backup single-quoted $(date ...), so the stamp sat literal in the filename. Now the timestamp is interpolated in Elisp with format-time-string. The dired menu used "M-S-d", which Meta-Shift-d never emits (it sends M-D), so the menu was unreachable in plain dired. It now binds M-D, matching the dirvish sibling. Both command strings moved to top-level builders so they're unit-testable without loading the dwim-shell-command package.
Diffstat (limited to 'tests/test-dwim-shell-config-command-fixes.el')
-rw-r--r--tests/test-dwim-shell-config-command-fixes.el33
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/test-dwim-shell-config-command-fixes.el b/tests/test-dwim-shell-config-command-fixes.el
new file mode 100644
index 00000000..2f49a868
--- /dev/null
+++ b/tests/test-dwim-shell-config-command-fixes.el
@@ -0,0 +1,33 @@
+;;; test-dwim-shell-config-command-fixes.el --- zip/backup command builders -*- lexical-binding: t; -*-
+
+;;; Commentary:
+;; Two audit fixes, extracted into top-level command-string builders so they're
+;; testable without loading the dwim-shell-command package (the command defuns
+;; that call them live inside its use-package :config, which the batch test
+;; harness doesn't instantiate):
+;; - cj/dwim-shell--zip-single-file-command names the archive <fne>.zip
+;; - cj/dwim-shell--dated-backup-command carries a real timestamp, not "$(date)"
+;; The third fix (dired menu key M-S-d -> M-D) is a keybinding inside the same
+;; :config block; it's verified in the live daemon, not here.
+
+;;; Code:
+
+(require 'ert)
+(require 'dwim-shell-config)
+
+(ert-deftest test-dwim-zip-single-file-command-names-archive-dot-zip ()
+ "Normal: the single-file zip template names the archive <fne>.zip, with no
+leftover <<e>> that would rebuild the input filename."
+ (let ((cmd (cj/dwim-shell--zip-single-file-command)))
+ (should (string-match-p "'<<fne>>\\.zip'" cmd))
+ (should-not (string-match-p "<<e>>" cmd))))
+
+(ert-deftest test-dwim-dated-backup-command-carries-real-timestamp ()
+ "Normal: the dated-backup template interpolates a real YYYYMMDD_HHMMSS stamp,
+so the substitution can't sit dead inside single quotes."
+ (let ((cmd (cj/dwim-shell--dated-backup-command)))
+ (should (string-match-p "\\.[0-9]\\{8\\}_[0-9]\\{6\\}\\.bak'" cmd))
+ (should-not (string-match-p "\\$(date" cmd))))
+
+(provide 'test-dwim-shell-config-command-fixes)
+;;; test-dwim-shell-config-command-fixes.el ends here