(use-modules (srfi srfi-64) (stash conflict) (test-helpers)) (test-begin "conflict") ;; Test conflict detection (test-group "conflict-detection" (with-temporary-directory temp-dir ;; Setup test scenario (let* ((source-path (string-append temp-dir "/source/config")) (target-path (string-append temp-dir "/target/config"))) ;; Test case 1: No conflict (target doesn't exist) (create-test-file source-path "source content") (test-assert "Should not detect conflict when target doesn't exist" (not (has-conflict? source-path target-path))) ;; Test case 2: Conflict with existing file (create-test-file target-path "target content") (test-assert "Should detect conflict with existing file" (has-conflict? source-path target-path)) ;; Test case 3: Conflict with directory (delete-file target-path) (mkdir target-path) (test-assert "Should detect conflict with directory" (has-conflict? source-path target-path))))) ;; Test conflict resolution strategies (test-group "conflict-resolution" (with-temporary-directory temp-dir (let* ((source-path (string-append temp-dir "/source/config")) (target-path (string-append temp-dir "/target/config"))) ;; Setup test files (create-test-file source-path "source content") (create-test-file target-path "target content") ;; Test backup strategy (test-assert "Backup strategy should succeed" (resolve-conflict source-path target-path 'backup)) (test-assert "Backup file should exist" (file-exists? (string-append target-path ".bak"))) ;; Test overwrite strategy (create-test-file target-path "target content") (test-assert "Overwrite strategy should succeed" (resolve-conflict source-path target-path 'overwrite)) (test-equal "Target should contain source content" "source content" (with-input-from-file target-path read-string)) ;; Test skip strategy (test-assert "Skip strategy should succeed" (resolve-conflict source-path target-path 'skip)) (test-equal "Target should remain unchanged" "source content" (with-input-from-file target-path read-string))))) (test-end "conflict")