aboutsummaryrefslogtreecommitdiff
path: root/tests/test-pearl-bugfixes.el
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-06-02 20:27:38 -0500
committerCraig Jennings <c@cjennings.net>2026-06-02 20:27:38 -0500
commitfac5c2973b4d6e028c203a4bad0ba104178e1349 (patch)
tree4ba944ac46d17c45fd66375a71406b447ea174f2 /tests/test-pearl-bugfixes.el
parent9a145f30ff49a0141f342ea775e8f1a5b5899ae6 (diff)
downloadpearl-fac5c2973b4d6e028c203a4bad0ba104178e1349.tar.gz
pearl-fac5c2973b4d6e028c203a4bad0ba104178e1349.zip
fix(priority): error on an out-of-range cookie instead of silent None
pearl--priority-number-at-point matched only [#A-D], so a cookie outside that range (a hand-typed [#E], say) didn't match and fell through to 0 (None). On save that silently pushed None to Linear and cleared the issue's priority, with no error and no sign anything was wrong. It now matches any [#A-Z] and, when the letter isn't A-D, signals a user-error naming the valid range (A=Urgent, B=High, C=Medium, D=Low, or no cookie for None), so a stray cookie surfaces before any push rather than quietly wiping the priority. Linear has exactly five priorities, so A-D plus no-cookie is the whole range.
Diffstat (limited to 'tests/test-pearl-bugfixes.el')
-rw-r--r--tests/test-pearl-bugfixes.el23
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/test-pearl-bugfixes.el b/tests/test-pearl-bugfixes.el
index c1348f1..3d8d53e 100644
--- a/tests/test-pearl-bugfixes.el
+++ b/tests/test-pearl-bugfixes.el
@@ -150,5 +150,28 @@
(should-error (pearl-run-local-view "bad") :type 'user-error)
(should-not fetched))))
+;;; Bug: an out-of-range priority cookie ([#E]) silently downgraded to None
+
+(ert-deftest test-pearl-priority-number-in-range ()
+ "A/B/C/D cookies map to Linear 1-4; a heading with no cookie is 0 (None)."
+ (test-pearl-bug--in-org "* TODO [#A] Urgent issue\n"
+ (should (= 1 (pearl--priority-number-at-point))))
+ (test-pearl-bug--in-org "* TODO [#C] Medium issue\n"
+ (should (= 3 (pearl--priority-number-at-point))))
+ (test-pearl-bug--in-org "* TODO [#D] Low issue\n"
+ (should (= 4 (pearl--priority-number-at-point))))
+ (test-pearl-bug--in-org "* TODO No cookie issue\n"
+ (should (= 0 (pearl--priority-number-at-point)))))
+
+(ert-deftest test-pearl-priority-number-out-of-range-errors ()
+ "An out-of-range cookie ([#E]) signals a user-error, not a silent None.
+The old reader matched only [#A-D], so [#E] fell through to 0 and a save
+silently pushed None, clearing the issue's Linear priority. Now it refuses
+at read time so the bad cookie surfaces before any push."
+ (test-pearl-bug--in-org "* TODO [#E] Bogus priority\n"
+ (should-error (pearl--priority-number-at-point) :type 'user-error))
+ (test-pearl-bug--in-org "* TODO [#Z] Also bogus\n"
+ (should-error (pearl--priority-number-at-point) :type 'user-error)))
+
(provide 'test-pearl-bugfixes)
;;; test-pearl-bugfixes.el ends here