branch: externals/vc-jj
commit ebe6d542580e353ea507c6120525dea71b558de6
Author: Kristoffer Balintona <krisbalint...@gmail.com>
Commit: Kristoffer Balintona <krisbalint...@gmail.com>

    Tests: Check in files when given directory path
    
    This test ensures that all changed files in a subdirectory are
    recursively checked in (i.e, committed) when a directory path is
    passed to `vc-jj-checkin`.
---
 vc-jj-tests.el | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/vc-jj-tests.el b/vc-jj-tests.el
index 1261124b1d..28df2ef642 100644
--- a/vc-jj-tests.el
+++ b/vc-jj-tests.el
@@ -208,6 +208,27 @@ is needed."
       (should (equal (vc-jj-dir-status-files (expand-file-name "subdir/" repo) 
nil (lambda (x y) x))
                      '(("conflicted.txt" conflict)))))))
 
+(ert-deftest vc-jj-checkin-directory ()
+  "Test checking in an entire directory of files.
+This tests when a subdirectory path is passed to `vc-jj-checkin', rather
+than a path to a regular file."
+  ;; https://codeberg.org/emacs-jj-vc/vc-jj.el/issues/62
+  (vc-jj-test-with-repo repo
+    (make-directory "subdir")
+    (write-region "foo" nil "subdir/file1.txt")
+    (write-region "bar" nil "subdir/file2.txt")
+    (make-directory "subdir/deeper_subdir")
+    (write-region "baz" nil "subdir/deeper_subdir/file3.txt")
+    (should (eq (vc-jj-state "subdir/file1.txt") 'added))
+    (should (eq (vc-jj-state "subdir/file2.txt") 'added))
+    (should (eq (vc-jj-state "subdir/deeper_subdir/file3.txt") 'added))
+    (vc-jj-checkin (list "subdir/") "Sample commit message")
+    (should (seq-set-equal-p
+             (vc-jj-dir-status-files repo nil (lambda (x y) x))
+             '(("subdir/file1.txt" up-to-date)
+               ("subdir/file2.txt" up-to-date)
+               ("subdir/deeper_subdir/file3.txt" up-to-date))))))
+
 (ert-deftest vc-jj-funky-filename ()
   ;; https://codeberg.org/emacs-jj-vc/vc-jj.el/issues/38
   (vc-jj-test-with-repo repo

Reply via email to