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 | bdf3058542bbce298b435b301c7863b9d81d5bf4 (patch) | |
| tree | 4905253aa528d743ae7479be6ed0cbabe9b3b4b2 /tests/test-reconcile--should-skip-p.el | |
| parent | 5cd7ca13005680b3e7bdac48dedf9cfbbfbcaa59 (diff) | |
| download | dotemacs-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--should-skip-p.el')
| -rw-r--r-- | tests/test-reconcile--should-skip-p.el | 101 |
1 files changed, 101 insertions, 0 deletions
diff --git a/tests/test-reconcile--should-skip-p.el b/tests/test-reconcile--should-skip-p.el new file mode 100644 index 00000000..3e9c0177 --- /dev/null +++ b/tests/test-reconcile--should-skip-p.el @@ -0,0 +1,101 @@ +;;; test-reconcile--should-skip-p.el --- Tests for cj/reconcile--should-skip-p -*- lexical-binding: t; -*- + +;;; Commentary: +;; Tests for the skip predicate that filters out non-git dirs, local-only repos, +;; and http/https reference clones. + +;;; Code: + +(require 'ert) +(require 'testutil-reconcile-open-repos) +(require 'reconcile-open-repos) + +;;; Normal Cases + +(ert-deftest test-should-skip-p-normal-ssh-remote-not-skipped () + "SSH remote repo should NOT be skipped." + (reconcile-test-with-temp-dirs + ("repo/.git/") + (let ((dir (expand-file-name "repo" test-root))) + (reconcile-test-with-shell-mocks + (lambda (_cmd) 0) + (lambda (cmd) + (if (string-match-p "remote.origin.url" cmd) + "git@github.com:user/repo.git" + "")) + (should-not (cj/reconcile--should-skip-p dir)))))) + +(ert-deftest test-should-skip-p-normal-http-remote-skipped () + "HTTP remote repo should be skipped (reference clone)." + (reconcile-test-with-temp-dirs + ("repo/.git/") + (let ((dir (expand-file-name "repo" test-root))) + (reconcile-test-with-shell-mocks + (lambda (_cmd) 0) + (lambda (cmd) + (if (string-match-p "remote.origin.url" cmd) + "http://github.com/user/repo.git" + "")) + (should (cj/reconcile--should-skip-p dir)))))) + +(ert-deftest test-should-skip-p-normal-https-remote-skipped () + "HTTPS remote repo should be skipped (reference clone)." + (reconcile-test-with-temp-dirs + ("repo/.git/") + (let ((dir (expand-file-name "repo" test-root))) + (reconcile-test-with-shell-mocks + (lambda (_cmd) 0) + (lambda (cmd) + (if (string-match-p "remote.origin.url" cmd) + "https://github.com/user/repo.git" + "")) + (should (cj/reconcile--should-skip-p dir)))))) + +(ert-deftest test-should-skip-p-normal-no-remote-skipped () + "Local-only repo (no remote) should be skipped." + (reconcile-test-with-temp-dirs + ("repo/.git/") + (let ((dir (expand-file-name "repo" test-root))) + (reconcile-test-with-shell-mocks + (lambda (_cmd) 0) + (lambda (cmd) + (if (string-match-p "remote.origin.url" cmd) "" "")) + (should (cj/reconcile--should-skip-p dir)))))) + +;;; Boundary Cases + +(ert-deftest test-should-skip-p-boundary-no-git-dir () + "Directory without .git should be skipped." + (reconcile-test-with-temp-dirs + ("not-a-repo/readme.txt") + (let ((dir (expand-file-name "not-a-repo" test-root))) + (should (cj/reconcile--should-skip-p dir))))) + +(ert-deftest test-should-skip-p-boundary-scp-style-remote-not-skipped () + "SCP-style remote (user@host:path) should NOT be skipped." + (reconcile-test-with-temp-dirs + ("repo/.git/") + (let ((dir (expand-file-name "repo" test-root))) + (reconcile-test-with-shell-mocks + (lambda (_cmd) 0) + (lambda (cmd) + (if (string-match-p "remote.origin.url" cmd) + "user@myserver.com:repos/project.git" + "")) + (should-not (cj/reconcile--should-skip-p dir)))))) + +(ert-deftest test-should-skip-p-boundary-ssh-protocol-url-not-skipped () + "ssh:// protocol URL should NOT be skipped." + (reconcile-test-with-temp-dirs + ("repo/.git/") + (let ((dir (expand-file-name "repo" test-root))) + (reconcile-test-with-shell-mocks + (lambda (_cmd) 0) + (lambda (cmd) + (if (string-match-p "remote.origin.url" cmd) + "ssh://git@github.com/user/repo.git" + "")) + (should-not (cj/reconcile--should-skip-p dir)))))) + +(provide 'test-reconcile--should-skip-p) +;;; test-reconcile--should-skip-p.el ends here |
