From 56d95e96490732b4d88bcd0d8c16708b998be285 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Sun, 24 May 2026 15:02:33 -0500 Subject: test: cover the delete-failure branch keeping the subtree Added an ERT test that pearl-delete-current-issue, when the confirmation is given but pearl--delete-issue-async returns :success nil, leaves the issue subtree and its sibling intact rather than removing local state on a failed remote delete. The command already behaves correctly. 361 tests green. --- tests/test-pearl-delete.el | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'tests') diff --git a/tests/test-pearl-delete.el b/tests/test-pearl-delete.el index bd412c7..02d3380 100644 --- a/tests/test-pearl-delete.el +++ b/tests/test-pearl-delete.el @@ -93,5 +93,21 @@ (cl-letf (((symbol-function 'yes-or-no-p) (lambda (&rest _) t))) (should-error (pearl-delete-current-issue) :type 'user-error)))) +(ert-deftest test-pearl-delete-current-issue-failure-keeps-subtree () + "A confirmed delete that fails on the remote leaves the subtree and its sibling intact." + (test-pearl--in-org + "* Header\n\n*** TODO ENG-1 Doomed\n:PROPERTIES:\n:LINEAR-ID: a\n:LINEAR-IDENTIFIER: ENG-1\n:END:\nbody\n*** TODO ENG-2 Survivor\n:PROPERTIES:\n:LINEAR-ID: b\n:END:\n" + (cl-letf (((symbol-function 'yes-or-no-p) (lambda (&rest _) t)) + ((symbol-function 'pearl--delete-issue-async) + (lambda (_id cb) (funcall cb '(:success nil))))) + (re-search-forward "Doomed") + (pearl-delete-current-issue) + ;; the failed delete leaves the issue in place ... + (goto-char (point-min)) + (should (re-search-forward "Doomed" nil t)) + ;; ... and the sibling subtree is untouched. + (goto-char (point-min)) + (should (re-search-forward "Survivor" nil t))))) + (provide 'test-pearl-delete) ;;; test-pearl-delete.el ends here -- cgit v1.2.3