diff options
| author | Craig Jennings <c@cjennings.net> | 2026-04-19 06:33:06 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2026-04-19 06:33:06 -0500 |
| commit | 1a8243e90499dab97463a783f76f10e40e7a38e4 (patch) | |
| tree | ce31d784911c522f292ab1a4148d9b7e3db247f4 /tests/test-reconcile--find-git-repos.el | |
| parent | ffd668b6394b2a0e2b538a7e472356a1636913fa (diff) | |
| download | dotemacs-1a8243e90499dab97463a783f76f10e40e7a38e4.tar.gz dotemacs-1a8243e90499dab97463a783f76f10e40e7a38e4.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--find-git-repos.el')
| -rw-r--r-- | tests/test-reconcile--find-git-repos.el | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/tests/test-reconcile--find-git-repos.el b/tests/test-reconcile--find-git-repos.el new file mode 100644 index 00000000..25987818 --- /dev/null +++ b/tests/test-reconcile--find-git-repos.el @@ -0,0 +1,77 @@ +;;; test-reconcile--find-git-repos.el --- Tests for cj/find-git-repos -*- lexical-binding: t; -*- + +;;; Commentary: +;; Tests for recursive git repository discovery in cj/find-git-repos. +;; Uses real temporary directory trees with fake .git directories. + +;;; Code: + +(require 'ert) +(require 'testutil-reconcile-open-repos) +(require 'reconcile-open-repos) + +;;; Normal Cases + +(ert-deftest test-find-git-repos-normal-flat-repos () + "Finds multiple git repos at the same level." + (reconcile-test-with-temp-dirs + ("repo-a/.git/" "repo-b/.git/" "repo-c/.git/") + (let ((repos (cj/find-git-repos test-root))) + (should (= (length repos) 3))))) + +(ert-deftest test-find-git-repos-normal-nested-repo () + "Finds a repo nested inside a non-repo directory." + (reconcile-test-with-temp-dirs + ("parent/child/.git/") + (let ((repos (cj/find-git-repos test-root))) + (should (= (length repos) 1)) + (should (string-suffix-p "child" (car repos)))))) + +(ert-deftest test-find-git-repos-normal-repo-with-nested-subrepo () + "Finds both a parent repo and a sub-repo inside it." + (reconcile-test-with-temp-dirs + ("deepsat/.git/" "deepsat/frontend/.git/" "deepsat/backend/.git/") + (let ((repos (cj/find-git-repos test-root))) + (should (= (length repos) 3))))) + +(ert-deftest test-find-git-repos-normal-mixed-repos-and-dirs () + "Finds repos while skipping plain directories." + (reconcile-test-with-temp-dirs + ("repo-a/.git/" "not-a-repo/readme.txt" "repo-b/.git/") + (let ((repos (cj/find-git-repos test-root))) + (should (= (length repos) 2))))) + +(ert-deftest test-find-git-repos-normal-deeply-nested () + "Finds a repo several levels deep." + (reconcile-test-with-temp-dirs + ("a/b/c/deep-repo/.git/") + (let ((repos (cj/find-git-repos test-root))) + (should (= (length repos) 1)) + (should (string-suffix-p "deep-repo" (car repos)))))) + +;;; Boundary Cases + +(ert-deftest test-find-git-repos-boundary-empty-directory () + "Returns empty list for directory with no children." + (reconcile-test-with-temp-dirs + () + (let ((repos (cj/find-git-repos test-root))) + (should (= (length repos) 0))))) + +(ert-deftest test-find-git-repos-boundary-no-git-repos () + "Returns empty list when no directories contain .git." + (reconcile-test-with-temp-dirs + ("dir-a/file.txt" "dir-b/file.txt") + (let ((repos (cj/find-git-repos test-root))) + (should (= (length repos) 0))))) + +(ert-deftest test-find-git-repos-boundary-hidden-dirs-skipped () + "Skips hidden directories (starting with dot) per the regex filter." + (reconcile-test-with-temp-dirs + (".hidden-repo/.git/" "visible-repo/.git/") + (let ((repos (cj/find-git-repos test-root))) + (should (= (length repos) 1)) + (should (string-suffix-p "visible-repo" (car repos)))))) + +(provide 'test-reconcile--find-git-repos) +;;; test-reconcile--find-git-repos.el ends here |
