aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-05-26 17:01:03 -0500
committerCraig Jennings <c@cjennings.net>2026-05-26 17:01:03 -0500
commit8e5efcab4043ef9824456e96f056bb99440b3ec4 (patch)
treeb8798bdd43ee924d427a0519e84ad2161ff8fcbf /tests
parent93dba546208d0e0889ef97d93de7943eb3c8e912 (diff)
downloaddotemacs-8e5efcab4043ef9824456e96f056bb99440b3ec4.tar.gz
dotemacs-8e5efcab4043ef9824456e96f056bb99440b3ec4.zip
feat(projectile): open the project daily prep on C-c p d
I added cj/open-project-daily-prep on C-c p d. It opens inbox/today-prep.org under the Projectile project root in another window, project-scoped, so a project without a prep file just reports it rather than erroring. The binding had only ever been eval'd live into the daemon in a past session and vanished on the next restart, so this persists it to the module. Freeing d meant reworking the deadgrep bindings. deadgrep-in-dir moves to C-c p G (replacing plain deadgrep, which stays M-x-callable), and deadgrep-here keeps C-c p g. Plain project-wide deadgrep dropped off the projectile prefix because it overlapped the context-aware and arbitrary-directory variants. Tests cover the open, missing-file, and not-in-a-project paths.
Diffstat (limited to 'tests')
-rw-r--r--tests/test-prog-general-open-project-daily-prep.el57
1 files changed, 57 insertions, 0 deletions
diff --git a/tests/test-prog-general-open-project-daily-prep.el b/tests/test-prog-general-open-project-daily-prep.el
new file mode 100644
index 00000000..9a38757a
--- /dev/null
+++ b/tests/test-prog-general-open-project-daily-prep.el
@@ -0,0 +1,57 @@
+;;; test-prog-general-open-project-daily-prep.el --- daily-prep opener -*- lexical-binding: t; -*-
+
+;;; Commentary:
+;; `cj/open-project-daily-prep' (C-c p d) opens inbox/today-prep.org under the
+;; current Projectile project root, in another window. It is project-scoped:
+;; projects without a prep file get a message instead. `projectile-project-root'
+;; (external project state) and `find-file-other-window' (the window/visit
+;; boundary) are stubbed; real temp directories drive the file-exists check, and
+;; the message branches are checked via the command's return value rather than
+;; by stubbing `message'.
+
+;;; Code:
+
+(require 'ert)
+(require 'cl-lib)
+(add-to-list 'load-path (expand-file-name "modules" user-emacs-directory))
+(require 'prog-general)
+
+(ert-deftest test-prog-general-daily-prep-opens-existing-in-other-window ()
+ "Normal: in a project with a prep file, open it in another window."
+ (let* ((root (file-name-as-directory (make-temp-file "cj-prep-" t)))
+ (prep (expand-file-name "inbox/today-prep.org" root))
+ opened)
+ (unwind-protect
+ (progn
+ (make-directory (expand-file-name "inbox" root) t)
+ (write-region "" nil prep)
+ (cl-letf (((symbol-function 'projectile-project-root) (lambda () root))
+ ((symbol-function 'find-file-other-window) (lambda (f) (setq opened f))))
+ (cj/open-project-daily-prep))
+ (should (equal opened prep)))
+ (delete-directory root t))))
+
+(ert-deftest test-prog-general-daily-prep-missing-file-messages ()
+ "Boundary: in a project without a prep file, do not open; report it."
+ (let* ((root (file-name-as-directory (make-temp-file "cj-prep-" t)))
+ opened result)
+ (unwind-protect
+ (progn
+ (cl-letf (((symbol-function 'projectile-project-root) (lambda () root))
+ ((symbol-function 'find-file-other-window) (lambda (f) (setq opened f))))
+ (setq result (cj/open-project-daily-prep)))
+ (should-not opened)
+ (should (string-match-p "No inbox/today-prep.org" result)))
+ (delete-directory root t))))
+
+(ert-deftest test-prog-general-daily-prep-not-in-project-messages ()
+ "Error: outside a Projectile project, do not open; report it."
+ (let (opened result)
+ (cl-letf (((symbol-function 'projectile-project-root) (lambda () nil))
+ ((symbol-function 'find-file-other-window) (lambda (f) (setq opened f))))
+ (setq result (cj/open-project-daily-prep)))
+ (should-not opened)
+ (should (string-match-p "Not in a Projectile project" result))))
+
+(provide 'test-prog-general-open-project-daily-prep)
+;;; test-prog-general-open-project-daily-prep.el ends here