From 0a65ae7c57aecbb948a3cf9675564b731efee55d Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Sun, 24 May 2026 15:15:55 -0500 Subject: 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. --- tests/test-pearl-output.el | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) 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 () -- cgit v1.2.3