From bdf3058542bbce298b435b301c7863b9d81d5bf4 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Sun, 19 Apr 2026 06:33:06 -0500 Subject: refactor(reconcile): extract helpers, add recursive repo discovery and 28 tests Extract should-skip-p, pull-clean, pull-dirty from 6-level nested reconcile-git-directory. Make find-git-repos recurse into sub-repos. --- tests/test-reconcile--pull-clean.el | 60 +++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 tests/test-reconcile--pull-clean.el (limited to 'tests/test-reconcile--pull-clean.el') diff --git a/tests/test-reconcile--pull-clean.el b/tests/test-reconcile--pull-clean.el new file mode 100644 index 00000000..a10c6f1e --- /dev/null +++ b/tests/test-reconcile--pull-clean.el @@ -0,0 +1,60 @@ +;;; test-reconcile--pull-clean.el --- Tests for cj/reconcile--pull-clean -*- lexical-binding: t; -*- + +;;; Commentary: +;; Tests for pulling latest changes on a clean git repository. + +;;; Code: + +(require 'ert) +(require 'testutil-reconcile-open-repos) +(require 'reconcile-open-repos) + +;;; Normal Cases + +(ert-deftest test-pull-clean-normal-success () + "Successful pull produces no warning message." + (reconcile-test-with-temp-dirs + ("repo/.git/") + (let ((dir (expand-file-name "repo" test-root)) + (messages nil)) + (reconcile-test-with-shell-mocks + (lambda (_cmd) 0) + (lambda (_cmd) "") + (cl-letf (((symbol-function 'message) + (lambda (fmt &rest args) (push (apply #'format fmt args) messages)))) + (cj/reconcile--pull-clean dir))) + (should-not (cl-some (lambda (m) (string-match-p "Warning" m)) messages))))) + +(ert-deftest test-pull-clean-normal-failure-warns () + "Failed pull produces a warning message with directory and exit code." + (reconcile-test-with-temp-dirs + ("repo/.git/") + (let ((dir (expand-file-name "repo" test-root)) + (messages nil)) + (reconcile-test-with-shell-mocks + (lambda (_cmd) 1) + (lambda (_cmd) "") + (cl-letf (((symbol-function 'message) + (lambda (fmt &rest args) (push (apply #'format fmt args) messages)))) + (cj/reconcile--pull-clean dir))) + (should (cl-some (lambda (m) (string-match-p "Warning.*git pull failed" m)) messages)) + (should (cl-some (lambda (m) (string-match-p "exit code: 1" m)) messages))))) + +;;; Boundary Cases + +(ert-deftest test-pull-clean-boundary-nonzero-exit-128 () + "Exit code 128 (common git error) is reported in warning." + (reconcile-test-with-temp-dirs + ("repo/.git/") + (let ((dir (expand-file-name "repo" test-root)) + (messages nil)) + (reconcile-test-with-shell-mocks + (lambda (_cmd) 128) + (lambda (_cmd) "") + (cl-letf (((symbol-function 'message) + (lambda (fmt &rest args) (push (apply #'format fmt args) messages)))) + (cj/reconcile--pull-clean dir))) + (should (cl-some (lambda (m) (string-match-p "exit code: 128" m)) messages))))) + +(provide 'test-reconcile--pull-clean) +;;; test-reconcile--pull-clean.el ends here -- cgit v1.2.3