From df4caddc17091b67b5afa7864b53ccffc00ce076 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Tue, 5 May 2026 14:35:45 -0500 Subject: test: cover --pick-next-marker and resume happy-paths MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I extended `tests/test-org-drill-route-rating-result.el' with four `org-drill--pick-next-marker' cases (no resume → pop, resume with live drill marker → keep current-item and clear resume-p, resume with nil or non-drill current-item → fall through to fresh pop). I also extended the resume regression file with the three happy-path branches of `org-drill-resume': pending entries → resume, finished with pending count → y-or-n-p offers a new session, finished with nothing → print 'finished'. Coverage moved from 91.7% to 92.1%. --- tests/test-org-drill-route-rating-result.el | 50 +++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) (limited to 'tests/test-org-drill-route-rating-result.el') diff --git a/tests/test-org-drill-route-rating-result.el b/tests/test-org-drill-route-rating-result.el index 5469bc8..5ea29b7 100644 --- a/tests/test-org-drill-route-rating-result.el +++ b/tests/test-org-drill-route-rating-result.el @@ -67,5 +67,55 @@ (org-drill--route-rating-result session m1 0)) (should shuffle-called))) +;;;; org-drill--pick-next-marker + +(ert-deftest test-pick-next-marker-not-resuming-pops-from-queue () + "Without resuming-p, the result is the popped pending entry." + (let ((session (org-drill-session))) + (cl-letf (((symbol-function 'org-drill-pop-next-pending-entry) + (lambda (_) 'popped-marker))) + (let ((result (org-drill--pick-next-marker session nil))) + (should (equal '(popped-marker . nil) result)))))) + +(ert-deftest test-pick-next-marker-resuming-with-current-item-keeps-it () + "When resuming-p is t and current-item is a live drill entry, return it +and flip resume-p to nil so subsequent ticks don't repeat the same entry." + (let ((session (org-drill-session))) + (with-temp-buffer + (insert "* Drill :drill:\nbody\n") + (org-mode) + (goto-char (point-min)) + (let ((m (point-marker))) + (oset session current-item m) + (let ((result (org-drill--pick-next-marker session t))) + (should (eq m (car result))) + (should (null (cdr result)))))))) + +(ert-deftest test-pick-next-marker-resuming-with-nil-current-item-pops-fresh () + "When resuming-p is t but current-item is nil, fall through to popping a +fresh entry from the pending queue." + (let ((session (org-drill-session))) + (oset session current-item nil) + (cl-letf (((symbol-function 'org-drill-pop-next-pending-entry) + (lambda (_) 'fresh-marker))) + (let ((result (org-drill--pick-next-marker session t))) + (should (eq 'fresh-marker (car result))) + ;; resuming-p still flowing through. + (should (eq t (cdr result))))))) + +(ert-deftest test-pick-next-marker-resuming-with-non-drill-current-item-pops-fresh () + "When current-item is set but no longer points at a drill entry, fall +through to popping a fresh entry." + (let ((session (org-drill-session))) + (with-temp-buffer + (insert "Plain text — not a drill heading.\n") + (org-mode) + (goto-char (point-min)) + (oset session current-item (point-marker)) + (cl-letf (((symbol-function 'org-drill-pop-next-pending-entry) + (lambda (_) 'fresh-marker))) + (let ((result (org-drill--pick-next-marker session t))) + (should (eq 'fresh-marker (car result)))))))) + (provide 'test-org-drill-route-rating-result) ;;; test-org-drill-route-rating-result.el ends here -- cgit v1.2.3