aboutsummaryrefslogtreecommitdiff
path: root/tests/test-pearl-bugfixes.el
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test-pearl-bugfixes.el')
-rw-r--r--tests/test-pearl-bugfixes.el25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/test-pearl-bugfixes.el b/tests/test-pearl-bugfixes.el
index 7f5c635..caab884 100644
--- a/tests/test-pearl-bugfixes.el
+++ b/tests/test-pearl-bugfixes.el
@@ -151,5 +151,30 @@
(should-error (pearl-run-saved-query "bad") :type 'user-error)
(should-not fetched))))
+;;; Bug: async issue callbacks must be harmless if the buffer is killed
+
+(ert-deftest test-pearl-push-issue-field-killed-buffer-no-signal ()
+ "A field push whose buffer is killed before the success callback does not signal."
+ (let ((buf (generate-new-buffer "pearl-pif-kill")))
+ (unwind-protect
+ (let (marker)
+ (with-current-buffer buf
+ (insert "* h\n:PROPERTIES:\n:LINEAR-ID: a\n:END:\nbody\n")
+ (org-mode)
+ (goto-char (point-min))
+ (setq marker (point-marker)))
+ ;; The update stub kills the buffer, then reports success; the success
+ ;; callback must not run its buffer ops (or signal) on a dead buffer.
+ (cl-letf (((symbol-function 'pearl--update-issue-async)
+ (lambda (_id _fields cb) (kill-buffer buf) (funcall cb '(:success t)))))
+ ;; Must complete without signaling; the on-success thunk (which would
+ ;; error) must not run because the buffer is dead.
+ (pearl--push-issue-field
+ "a" marker '(("priority" . 2))
+ (lambda () (error "on-success must not run against a dead buffer"))
+ "ok" "fail")
+ (should-not (buffer-live-p buf))))
+ (when (buffer-live-p buf) (kill-buffer buf)))))
+
(provide 'test-pearl-bugfixes)
;;; test-pearl-bugfixes.el ends here