aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-05-23 13:05:33 -0500
committerCraig Jennings <c@cjennings.net>2026-05-23 13:05:33 -0500
commit6eff37f3a92817ce8ef9909a3fb8f831b9591d71 (patch)
treec52f328000809970617e1912c3c4029688430a4c /tests
parentde2d02732a39cee56ba70b1f3d50e2784e24c53e (diff)
downloaddotemacs-6eff37f3a92817ce8ef9909a3fb8f831b9591d71.tar.gz
dotemacs-6eff37f3a92817ce8ef9909a3fb8f831b9591d71.zip
fix(linear): load API key for check-setup and pin org file to emacs home
linear-emacs-check-setup read linear-emacs-api-key directly and bailed to "API key is not set" before making any request, so the lazy :before advice on the GraphQL request never fired for it. A fresh session always reported the key missing even though it was in authinfo. I extracted cj/linear--install-key-advice and put the loader on check-setup as well as the request entry point, with a regression test. I also pinned linear-emacs-org-file-path to data/linear.org inside emacs home, next to the calendar-sync output. Left to its default it falls back to org-directory/gtd/linear.org and silently created a stray ~/org tree on the first pull. The init.el require is commented out for now while linear-emacs is reworked. The config will need rework once that lands.
Diffstat (limited to 'tests')
-rw-r--r--tests/test-linear-config.el23
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/test-linear-config.el b/tests/test-linear-config.el
index c3e702d8b..5a6e36a85 100644
--- a/tests/test-linear-config.el
+++ b/tests/test-linear-config.el
@@ -41,6 +41,29 @@
(cj/linear--ensure-api-key)
(should-not linear-emacs-api-key))))
+(ert-deftest test-linear-install-key-advice-loads-before-check-setup ()
+ "Error-regression: `linear-emacs-check-setup' loads the key before reading it.
+The lazy loader originally only advised the GraphQL request entry point, so
+`check-setup' — which reads `linear-emacs-api-key' directly without making a
+request — falsely reported \"not set\" on a fresh session."
+ (let ((linear-emacs-api-key nil)
+ (key-at-read :unread))
+ (cl-letf (((symbol-function 'cj/auth-source-secret-value)
+ (lambda (&rest _) "lin_api_test"))
+ ((symbol-function 'linear-emacs--graphql-request-async)
+ (lambda (&rest _) nil))
+ ((symbol-function 'linear-emacs-check-setup)
+ (lambda () (setq key-at-read linear-emacs-api-key))))
+ (cj/linear--install-key-advice)
+ (unwind-protect
+ (progn
+ (linear-emacs-check-setup)
+ (should (equal key-at-read "lin_api_test")))
+ (advice-remove 'linear-emacs--graphql-request-async
+ #'cj/linear--ensure-key-before)
+ (advice-remove 'linear-emacs-check-setup
+ #'cj/linear--ensure-key-before)))))
+
(ert-deftest test-linear-keymap-bound-under-prefix ()
"Smoke: C-; L holds the linear keymap and the entry commands are bound."
(should (keymapp cj/linear-keymap))