Personal emacs config
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

63 lines
2.5 KiB

  1. ;;; dired-rsync-ert --- tests for dired-rsync
  2. ;;
  3. ;;; Commentary:
  4. ;;
  5. ;; Mostly this is for the internal functions as it is hard to test
  6. ;; remote SSH accessible resources in a test case.
  7. ;;
  8. ;;; Code:
  9. (require 'ert)
  10. (when (require 'undercover nil t)
  11. (undercover "dired-rsync.el"))
  12. (require 'dired-rsync)
  13. (ert-deftest dired-rsync-test-extract-host ()
  14. "Test the various extractions of host from sources."
  15. (should (string-equal "host"
  16. (dired-rsync--extract-host-from-tramp
  17. "/ssh:host:/path/to/file.txt")))
  18. (should (string-equal "user@host"
  19. (dired-rsync--extract-host-from-tramp
  20. "/ssh:user@host:/path/to/file.txt")))
  21. (should (string-equal "host"
  22. (dired-rsync--extract-host-from-tramp
  23. "/ssh:user@host:/path/to/file.txt" t))))
  24. (ert-deftest dired-rsync-test-extract-user ()
  25. "Test the various extractions of user from paths."
  26. (should (string-equal "user"
  27. (dired-rsync--extract-user-from-tramp
  28. "/ssh:user@host:/path/to/file.txt"))))
  29. (ert-deftest dired-rsync-test-extract-path()
  30. "Test the various extractions of the path."
  31. (should (string-equal "/path/to/file.txt"
  32. (car (dired-rsync--extract-paths-from-tramp
  33. '("/ssh:host:/path/to/file.txt"
  34. "/ssh:host:/path/to/file2.txt")))))
  35. (should (string-equal "/path/to/file2.txt"
  36. (nth 1 (dired-rsync--extract-paths-from-tramp
  37. '("/ssh:host:/path/to/file.txt"
  38. "/ssh:host:/path/to/file2.txt")))))
  39. (should (string-equal "/path/to/file.txt"
  40. (car (dired-rsync--extract-paths-from-tramp
  41. '("/ssh:host:/path/to/file.txt")))))
  42. (should (string-equal "/path/to/pluralised\\'s.txt"
  43. (car (dired-rsync--extract-paths-from-tramp
  44. '("/ssh:host:/path/to/pluralised's.txt"))))))
  45. (ert-deftest dired-rsync-test-remote-remote-cmd ()
  46. "Test we generate a good remote to remote command."
  47. (should (string-equal
  48. "ssh -A -R localhost:50000:host:22 seed 'rsync -az --info=progress2 -e \"ssh -p 50000 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null\" a b c's user@localhost:/video'"
  49. (dired-rsync--remote-to-remote-cmd "seed" '("a" "b" "c's") "user"
  50. "host" "/video"))))
  51. ;;; dired-rsync-ert.el ends here