aboutsummaryrefslogtreecommitdiff
path: root/tests/test-reconcile--pull-clean.el
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-04-19 06:33:06 -0500
committerCraig Jennings <c@cjennings.net>2026-04-19 06:33:06 -0500
commitbdf3058542bbce298b435b301c7863b9d81d5bf4 (patch)
tree4905253aa528d743ae7479be6ed0cbabe9b3b4b2 /tests/test-reconcile--pull-clean.el
parent5cd7ca13005680b3e7bdac48dedf9cfbbfbcaa59 (diff)
downloaddotemacs-bdf3058542bbce298b435b301c7863b9d81d5bf4.tar.gz
dotemacs-bdf3058542bbce298b435b301c7863b9d81d5bf4.zip
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.
Diffstat (limited to 'tests/test-reconcile--pull-clean.el')
-rw-r--r--tests/test-reconcile--pull-clean.el60
1 files changed, 60 insertions, 0 deletions
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