aboutsummaryrefslogtreecommitdiff
path: root/tests/test-pearl-output.el
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-05-24 15:15:55 -0500
committerCraig Jennings <c@cjennings.net>2026-05-24 15:15:55 -0500
commit0a65ae7c57aecbb948a3cf9675564b731efee55d (patch)
tree8c7aa62a560b62dd13d6dc8d873eef2e304b0e20 /tests/test-pearl-output.el
parent6fca176d45b91d281bab36b51260e0ca1a788084 (diff)
downloadpearl-0a65ae7c57aecbb948a3cf9675564b731efee55d.tar.gz
pearl-0a65ae7c57aecbb948a3cf9675564b731efee55d.zip
test: cover malformed and unknown source headers
Added ERT tests for the generated #+LINEAR-SOURCE header: a syntactically malformed source line reads back nil (no reader error) and refresh-current-view surfaces the "no source recorded" user error; a valid-but-unknown :type reaches the "Unknown Linear source type" user error; and a source whose name and filter carry quotes, parens, colons, and non-ASCII round-trips through build-org-content and read-active-source unchanged. 375 tests green.
Diffstat (limited to 'tests/test-pearl-output.el')
-rw-r--r--tests/test-pearl-output.el32
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/test-pearl-output.el b/tests/test-pearl-output.el
index 79b7a82..f9f66eb 100644
--- a/tests/test-pearl-output.el
+++ b/tests/test-pearl-output.el
@@ -103,6 +103,38 @@
(org-mode)
(should-error (pearl-refresh-current-view) :type 'user-error)))
+;;; malformed / unknown source headers
+
+(ert-deftest test-pearl-read-active-source-malformed-is-nil ()
+ "A syntactically malformed #+LINEAR-SOURCE: line reads back nil, not a reader error."
+ (with-temp-buffer
+ (insert "#+title: x\n#+LINEAR-SOURCE: (:type filter :filter (:assignee\n\n")
+ (should-not (pearl--read-active-source))))
+
+(ert-deftest test-pearl-refresh-current-view-malformed-source-errors ()
+ "A malformed source header surfaces the no-source user error, not a reader error."
+ (with-temp-buffer
+ (insert "#+title: x\n#+LINEAR-SOURCE: (:type filter :filter (:assignee\n")
+ (org-mode)
+ (should-error (pearl-refresh-current-view) :type 'user-error)))
+
+(ert-deftest test-pearl-refresh-current-view-unknown-type-errors ()
+ "A source with a valid but unknown :type signals the unknown-type user error."
+ (with-temp-buffer
+ (insert (format "#+title: x\n#+LINEAR-SOURCE: %s\n"
+ (prin1-to-string '(:type bogus :name "x"))))
+ (org-mode)
+ (should-error (pearl-refresh-current-view) :type 'user-error)))
+
+(ert-deftest test-pearl-source-header-roundtrips-special-chars ()
+ "A source name/filter with quotes, parens, colons, and non-ASCII round-trips."
+ (let ((source '(:type filter
+ :name "Bugs: \"urgent\" (P1) — café"
+ :filter (:labels ("a:b" "(paren)" "naïve")))))
+ (with-temp-buffer
+ (insert (pearl--build-org-content '() source))
+ (should (equal source (pearl--read-active-source))))))
+
;;; --update-org-from-issues surfaces the result
(ert-deftest test-pearl-update-org-surfaces-fresh-buffer ()