aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/test-pearl-save.el26
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/test-pearl-save.el b/tests/test-pearl-save.el
index 8050e6d..1f4f273 100644
--- a/tests/test-pearl-save.el
+++ b/tests/test-pearl-save.el
@@ -288,6 +288,32 @@ the conflict choice (stubbed). Returns (:outcome :fetched :pushed :applied
(should (equal '("remote changed") (plist-get r :applied)))
(should (string= (secure-hash 'sha256 "remote changed") (plist-get r :hash)))))
+(ert-deftest test-pearl-save-field-push-killed-buffer-no-signal ()
+ "A text-field push whose buffer is killed before the success callback does not signal.
+The hash-advance and :after-push touch the marker; on a dead buffer they must be
+skipped, with the remote push still reported as pushed."
+ (let ((buf (generate-new-buffer "pearl-field-push-kill")) outcome after-ran)
+ (unwind-protect
+ (let (marker)
+ (with-current-buffer buf
+ (insert "* h\n:PROPERTIES:\n:LINEAR-ID: a\n:END:\n")
+ (org-mode)
+ (goto-char (point-min))
+ (setq marker (point-marker)))
+ (pearl--save-field-push
+ (list :issue-id "u" :identifier "ENG-1" :field 'title :marker marker
+ :prop "LINEAR-TITLE-SHA256" :label "ENG-1 title"
+ ;; the push kills the buffer, then reports success
+ :push (lambda (_text cb) (kill-buffer buf) (funcall cb '(:success t)))
+ ;; touching the dead marker would signal without the guard
+ :after-push (lambda (_r m) (setq after-ran t) (org-entry-put m "X" "y")))
+ "new text"
+ (lambda (o) (setq outcome o)))
+ (should-not (buffer-live-p buf))
+ (should (eq 'pushed (plist-get outcome :status)))
+ (should-not after-ran))
+ (when (buffer-live-p buf) (kill-buffer buf)))))
+
;;; --run-atomic-field-save (the per-field engine for enum/relation fields)
(cl-defun test-pearl-save--atomic (&key live baseline remote (push-success t) resolution)