summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorDavid Shepherd <davidshepherd7@gmail.com>2018-02-08 16:20:36 +0000
committerDavid Shepherd <davidshepherd7@gmail.com>2018-02-08 17:44:23 +0000
commite769d3741d1023af4f965609f75e3567c89de6f0 (patch)
tree63cece2bf0a4a17717dbfcbf2cd1e819ea16af46 /test
parentAdd support for file paths opened using tramp and sudo (diff)
downloademacs-terminal-here-e769d3741d1023af4f965609f75e3567c89de6f0.tar.gz
Add remote directory support
Fixes #11
Diffstat (limited to 'test')
-rw-r--r--test/terminal-here-test.el32
1 files changed, 24 insertions, 8 deletions
diff --git a/test/terminal-here-test.el b/test/terminal-here-test.el
index e92f92d..849f18d 100644
--- a/test/terminal-here-test.el
+++ b/test/terminal-here-test.el
@@ -67,7 +67,7 @@
(let ((project-root-finder (lambda () "" "vc-root")))
(validate-setq terminal-here-project-root-function project-root-finder)
(with-terminal-here-mocks
- (mock (terminal-here--do-launch "vc-root"))
+ (mock (terminal-here--run-command * "vc-root"))
(terminal-here-project-launch))))
(ert-deftest project-root-finds-nothing ()
@@ -78,18 +78,34 @@
(ert-deftest sudo-tramp ()
(with-terminal-here-mocks
- (mock (terminal-here--do-launch "/etc/emacs/"))
+ (mock (terminal-here--run-command * "/etc/emacs/"))
(terminal-here-launch-in-directory "/sudo:root@localhost:/etc/emacs/"))
(with-terminal-here-mocks
- (mock (terminal-here--do-launch "/etc/emacs/"))
+ (mock (terminal-here--run-command * "/etc/emacs/"))
(terminal-here-launch-in-directory "/sudo:postgres@localhost:/etc/emacs/"))
(with-terminal-here-mocks
- (mock (terminal-here--do-launch "/etc/emacs/"))
+ (mock (terminal-here--run-command * "/etc/emacs/"))
(terminal-here-launch-in-directory "/sudo:root@127.0.0.1:/etc/emacs/")))
-(ert-deftest other-tramp-paths-not-handled ()
- (should-error
- (terminal-here-launch-in-directory "/ssh:foo@bar.com:/home/foo/my-file")
- :type 'user-error))
+
+
+(ert-deftest parse-ssh-dir ()
+ (should (equal (terminal-here--parse-ssh-dir "/ssh:buildbot:/home/buildbot/") (list "buildbot" "/home/buildbot/")))
+ (should (equal (terminal-here--parse-ssh-dir "/ssh:david@pi:/home/pi/") (list "david@pi" "/home/pi/")))
+ (should (equal (terminal-here--parse-ssh-dir "/ssh:root@192.168.0.1:/etc/hosts") (list "root@192.168.0.1" "/etc/hosts")))
+
+ (should-not (terminal-here--parse-ssh-dir "/home/buildbot/"))
+ (should-not (terminal-here--parse-ssh-dir "/ssh/foo/bar")))
+
+(ert-deftest ssh-tramp ()
+ (cl-letf* ((launch-command nil)
+ ((symbol-function 'terminal-here--run-command)
+ (lambda (command _dir)
+ (setq launch-command command))))
+ (validate-setq terminal-here-command-flag "-k")
+ (terminal-here-launch-in-directory "/ssh:david@pi:/home/pi/")
+ (should (equal (car launch-command) "x-terminal-emulator"))
+ (should (equal (cadr launch-command) "-k"))
+ (should (equal (caddr launch-command) "ssh"))))