mirror of https://codeberg.org/glenneth/stash.git
56 lines
2.2 KiB
Scheme
56 lines
2.2 KiB
Scheme
(use-modules (srfi srfi-64)
|
|
(srfi srfi-1) ; For any
|
|
(stash tree)
|
|
(stash paths)
|
|
(test-helpers))
|
|
|
|
(test-begin "tree")
|
|
|
|
;; Test directory tree operations
|
|
(test-group "directory-tree"
|
|
(with-temporary-directory temp-dir
|
|
;; Create test directory structure
|
|
(create-test-file (string-append temp-dir "/file1.txt"))
|
|
(create-test-file (string-append temp-dir "/dir1/file2.txt"))
|
|
(create-test-file (string-append temp-dir "/dir1/subdir/file3.txt"))
|
|
|
|
;; Test directory scanning
|
|
(let ((tree (scan-directory temp-dir)))
|
|
(test-assert "Tree should contain root file"
|
|
(tree-contains? tree (string-append temp-dir "/file1.txt")))
|
|
|
|
(test-assert "Tree should contain nested file"
|
|
(tree-contains? tree (string-append temp-dir "/dir1/file2.txt")))
|
|
|
|
(test-assert "Tree should contain deeply nested file"
|
|
(tree-contains? tree (string-append temp-dir "/dir1/subdir/file3.txt"))))))
|
|
|
|
;; Test symlink planning
|
|
(test-group "symlink-planning"
|
|
(with-temporary-directory temp-dir
|
|
(let* ((source-dir (string-append temp-dir "/source"))
|
|
(target-dir (string-append temp-dir "/target")))
|
|
|
|
;; Create source files
|
|
(create-test-file (string-append source-dir "/config.txt"))
|
|
(create-test-file (string-append source-dir "/dir/nested.txt"))
|
|
|
|
;; Test operation planning
|
|
(let* ((tree (scan-directory source-dir))
|
|
(ops (plan-operations tree target-dir)))
|
|
(test-assert "Should plan to create target directory"
|
|
(any (lambda (op)
|
|
(and (eq? (car op) 'mkdir)
|
|
(string=? (cadr op)
|
|
(string-append target-dir "/dir"))))
|
|
ops))
|
|
|
|
(test-assert "Should plan to create symlinks"
|
|
(any (lambda (op)
|
|
(and (eq? (car op) 'symlink)
|
|
(string=? (caddr op)
|
|
(string-append target-dir "/config.txt"))))
|
|
ops))))))
|
|
|
|
(test-end "tree")
|