diff options
| author | Craig Jennings <c@cjennings.net> | 2026-05-23 09:51:55 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2026-05-23 09:51:55 -0500 |
| commit | b7323a37a37a5948716060edb508a4c5791117b5 (patch) | |
| tree | e5df1fe1b4db413244a5b5bcae52c08e2ef37a3c /tests | |
| parent | 73439eb11c1f5ddc35c2564e40b6f5997a19fa25 (diff) | |
| download | dotemacs-b7323a37a37a5948716060edb508a4c5791117b5.tar.gz dotemacs-b7323a37a37a5948716060edb508a4c5791117b5.zip | |
feat(linear): wire linear-emacs into the config for DeepSat
I added modules/linear-config.el to load the local linear-emacs checkout (the same :load-path + :ensure nil shape gptel and org-drill use) and point it at DeepSat's Linear workspace. The personal API key comes from authinfo.gpg, loaded lazily by a named :before advice on the request function, so there's no GPG prompt at startup. The default team is DeepSat's Software Engineering team, and the commands sit under a C-; L prefix.
Verified live against DeepSat: the connection authenticates, lists all five workspace teams, and pulls real issues (SE-*, DEE-*). Tests cover the key-loader (loads when unset, keeps an existing key, stays nil when absent) and the keymap wiring.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test-linear-config.el | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/tests/test-linear-config.el b/tests/test-linear-config.el new file mode 100644 index 00000000..c3e702d8 --- /dev/null +++ b/tests/test-linear-config.el @@ -0,0 +1,52 @@ +;;; test-linear-config.el --- Tests for linear-config.el -*- lexical-binding: t; -*- + +;;; Commentary: +;; Covers the lazy API-key loader and the keybinding wiring. linear-emacs +;; itself is never loaded here (it's a deferred :load-path package), so +;; `linear-emacs-api-key' is declared special below to make the dynamic +;; let-bindings reach `cj/linear--ensure-api-key'. `cj/auth-source-secret-value' +;; is stubbed — no authinfo.gpg / GPG access in the tests. + +;;; Code: + +(require 'ert) +(require 'cl-lib) +(require 'linear-config) + +;; linear-config declares this with a bare (defvar linear-emacs-api-key), which +;; is only file-local; declare it special here so the let-bindings are dynamic. +(defvar linear-emacs-api-key nil) + +(ert-deftest test-linear-ensure-api-key-loads-when-unset () + "Normal: an unset key is loaded from auth-source." + (let ((linear-emacs-api-key nil)) + (cl-letf (((symbol-function 'cj/auth-source-secret-value) + (lambda (&rest _) "lin_api_test"))) + (cj/linear--ensure-api-key) + (should (equal linear-emacs-api-key "lin_api_test"))))) + +(ert-deftest test-linear-ensure-api-key-keeps-existing () + "Boundary: an already-set key is neither overwritten nor re-fetched." + (let ((linear-emacs-api-key "already-set") (fetched nil)) + (cl-letf (((symbol-function 'cj/auth-source-secret-value) + (lambda (&rest _) (setq fetched t) "other"))) + (cj/linear--ensure-api-key) + (should (equal linear-emacs-api-key "already-set")) + (should-not fetched)))) + +(ert-deftest test-linear-ensure-api-key-nil-when-absent () + "Boundary: a missing authinfo entry leaves the key nil without error." + (let ((linear-emacs-api-key nil)) + (cl-letf (((symbol-function 'cj/auth-source-secret-value) (lambda (&rest _) nil))) + (cj/linear--ensure-api-key) + (should-not linear-emacs-api-key)))) + +(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)) + (should (eq (keymap-lookup (current-global-map) "C-; L") cj/linear-keymap)) + (should (eq (keymap-lookup cj/linear-keymap "l") #'linear-emacs-list-issues)) + (should (eq (keymap-lookup cj/linear-keymap "n") #'linear-emacs-new-issue))) + +(provide 'test-linear-config) +;;; test-linear-config.el ends here |
