aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-05-24 15:02:33 -0500
committerCraig Jennings <c@cjennings.net>2026-05-24 15:02:33 -0500
commit56d95e96490732b4d88bcd0d8c16708b998be285 (patch)
treeec726472493d99d439a7a00c503d7c891f3ab1da
parent1a26149d4d7f16adb1552ba31a2de290a5c86fc4 (diff)
downloadpearl-56d95e96490732b4d88bcd0d8c16708b998be285.tar.gz
pearl-56d95e96490732b4d88bcd0d8c16708b998be285.zip
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.
-rw-r--r--tests/test-pearl-delete.el16
1 files changed, 16 insertions, 0 deletions
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