diff options
Diffstat (limited to 'tests/test-pearl-sync.el')
| -rw-r--r-- | tests/test-pearl-sync.el | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/test-pearl-sync.el b/tests/test-pearl-sync.el index 6127914..738e3ff 100644 --- a/tests/test-pearl-sync.el +++ b/tests/test-pearl-sync.el @@ -202,5 +202,24 @@ helper (nil when never called); the update helper reports success." "* Just a plain heading\nno linear id here\n" (should-error (pearl-sync-current-issue) :type 'user-error))) +(ert-deftest test-pearl-sync-current-issue-push-failure-keeps-provenance () + "A failed description push keeps the hash, timestamp, and edited body for retry." + (let ((updates nil) + (stored (secure-hash 'sha256 "baseline remote"))) + (test-pearl--in-org + (format "*** TODO ENG-1 Title\n:PROPERTIES:\n:LINEAR-ID: a\n:LINEAR-DESC-SHA256: %s\n:LINEAR-DESC-UPDATED-AT: old\n:END:\nEdited body now.\n" + stored) + (cl-letf (((symbol-function 'pearl--fetch-issue-description-async) + (lambda (_id cb) (funcall cb '(:description "baseline remote" :updated-at "t0")))) + ((symbol-function 'pearl--update-issue-description-async) + (lambda (_id md cb) (push md updates) (funcall cb '(:success nil))))) + (pearl-sync-current-issue) + ;; the push was attempted with the rendered body ... + (should (equal (list (pearl--org-to-md "Edited body now.")) updates)) + ;; ... but provenance is not advanced and the edit stays for retry. + (should (string= stored (org-entry-get nil "LINEAR-DESC-SHA256"))) + (should (string= "old" (org-entry-get nil "LINEAR-DESC-UPDATED-AT"))) + (should (string= "Edited body now." (pearl--issue-body-at-point))))))) + (provide 'test-pearl-sync) ;;; test-pearl-sync.el ends here |
