aboutsummaryrefslogtreecommitdiff
path: root/tests/test-pearl-accounts.el
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-06-15 23:53:57 -0500
committerCraig Jennings <c@cjennings.net>2026-06-15 23:53:57 -0500
commite749badfd974de42fe8d7cdbe2bfa4fa3e0771b2 (patch)
treed8feeb841af8ede91f37c80d8cc2a31ec78ebc96 /tests/test-pearl-accounts.el
parent8d69468b8f0a2366dd99e66763d74d059e5379b0 (diff)
downloadpearl-e749badfd974de42fe8d7cdbe2bfa4fa3e0771b2.tar.gz
pearl-e749badfd974de42fe8d7cdbe2bfa4fa3e0771b2.zip
fix(api): signal missing-key as user-error with mode-aware advice
A missing API key raised a raw `error`, so it backtraced under `debug-on-error`, and the stale advice pointed at customizing `pearl-api-key`. Now `pearl--headers` signals a `user-error` and branches the advice by mode: accounts mode points at `pearl-accounts` and `pearl-switch-account`, legacy mode at `pearl-api-key` and `pearl-load-api-key-from-env`. The credential-source resolver's three failure paths become `user-error` too, since a bad credential is a config problem, not a bug.
Diffstat (limited to 'tests/test-pearl-accounts.el')
-rw-r--r--tests/test-pearl-accounts.el7
1 files changed, 7 insertions, 0 deletions
diff --git a/tests/test-pearl-accounts.el b/tests/test-pearl-accounts.el
index 7994905..4de9c2f 100644
--- a/tests/test-pearl-accounts.el
+++ b/tests/test-pearl-accounts.el
@@ -78,6 +78,13 @@
"An unrecognized source tag errors rather than silently yielding nil."
(should-error (pearl--resolve-api-key-source '(:bogus "x") "work") :type 'error))
+(ert-deftest test-pearl-resolve-api-key-source-missing-is-user-error ()
+ "A missing credential is a user-config problem, surfaced as a `user-error'."
+ (cl-letf (((symbol-function 'auth-source-search) (lambda (&rest _) nil)))
+ (should-error (pearl--resolve-api-key-source
+ '(:auth-source :host "api.linear.app" :user "work") "work")
+ :type 'user-error)))
+
;;; pearl--resolve-account
(ert-deftest test-pearl-resolve-account-returns-full-context ()