From 1a26149d4d7f16adb1552ba31a2de290a5c86fc4 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Sun, 24 May 2026 15:01:01 -0500 Subject: test: cover sync-back push-failure branches at the command level MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Added ERT tests that the three sync commands leave provenance untouched when the push fails (:success nil): pearl-sync-current-issue keeps LINEAR-DESC-SHA256 and -UPDATED-AT, pearl-sync-current-issue-title keeps LINEAR-TITLE-SHA256, and pearl-edit-current-comment keeps LINEAR-COMMENT-SHA256 — and in each case the edited text stays in the buffer for retry. Each test asserts the push was attempted with the rendered text. The commands already behave correctly; this locks it. 360 tests green. --- tests/test-pearl-title-sync.el | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'tests/test-pearl-title-sync.el') diff --git a/tests/test-pearl-title-sync.el b/tests/test-pearl-title-sync.el index 6fbd284..512794c 100644 --- a/tests/test-pearl-title-sync.el +++ b/tests/test-pearl-title-sync.el @@ -161,5 +161,21 @@ stripped heading, so an unedited bracketed title is never clobbered on Linear." (test-pearl--in-org "* Plain heading\nno id\n" (should-error (pearl-sync-current-issue-title) :type 'user-error))) +(ert-deftest test-pearl-sync-title-push-failure-keeps-provenance () + "A failed title push keeps the hash and the edited heading for retry." + (let ((updates nil) + (stored (secure-hash 'sha256 "Old Title"))) + (test-pearl--in-org + (format "*** TODO [#B] Edited Title\n:PROPERTIES:\n:LINEAR-ID: a\n:LINEAR-TITLE-SHA256: %s\n:END:\n" + stored) + (cl-letf (((symbol-function 'pearl--fetch-issue-title-async) + (lambda (_id cb) (funcall cb '(:title "Old Title" :updated-at "t0")))) + ((symbol-function 'pearl--update-issue-title-async) + (lambda (_id title cb) (push title updates) (funcall cb '(:success nil))))) + (pearl-sync-current-issue-title) + (should (equal '("Edited Title") updates)) + (should (string= stored (org-entry-get nil "LINEAR-TITLE-SHA256"))) + (should (string= "Edited Title" (pearl--issue-title-at-point))))))) + (provide 'test-pearl-title-sync) ;;; test-pearl-title-sync.el ends here -- cgit v1.2.3