diff options
author | Jon Pither <jon.pither@gmail.com> | 2013-08-14 07:34:30 +0100 |
---|---|---|
committer | Jon Pither <jon.pither@gmail.com> | 2013-08-18 19:05:01 +0100 |
commit | c6b6e19f6f7f5cf5f839cf31d33ea5e2cdd18934 (patch) | |
tree | 8fd416821d52f3353105e6a390e78e1822a6a9cf /test | |
parent | c97c6abeba2a8166c62818ef94fcf8a837299b5d (diff) |
Rotate and display nrepl connection
Diffstat (limited to 'test')
-rw-r--r-- | test/nrepl-tests.el | 46 |
1 files changed, 42 insertions, 4 deletions
diff --git a/test/nrepl-tests.el b/test/nrepl-tests.el index fd03766a..d6b0a876 100644 --- a/test/nrepl-tests.el +++ b/test/nrepl-tests.el @@ -30,6 +30,7 @@ (require 'ert) (require 'nrepl) +(require 'noflet) (ert-deftest test-nrepl-decode-string () (should (equal '("spam") (nrepl-decode "4:spam")))) @@ -203,7 +204,7 @@ (should (= (nth 2 info) 43)) (should (equal (nth 3 info) 'nrepl-warning-highlight-face))))) -(defmacro nrepl-test-with-two-buffers (buffer-names &rest body) +(defmacro nrepl-test-with-buffers (buffer-names &rest body) (lexical-let ((create (lambda (b) (list b `(generate-new-buffer " *temp*"))))) `(lexical-let (,@(mapcar create buffer-names)) (unwind-protect @@ -212,7 +213,7 @@ (ert-deftest test-nrepl-make-repl-connection-default () (lexical-let ((connections (nrepl-connection-buffers))) - (nrepl-test-with-two-buffers + (nrepl-test-with-buffers (a b) (should (get-buffer a)) (should (get-buffer b)) @@ -229,7 +230,7 @@ (ert-deftest test-nrepl-connection-buffers () (lexical-let ((connections (nrepl-connection-buffers))) - (nrepl-test-with-two-buffers + (nrepl-test-with-buffers (a b) (nrepl-make-repl-connection-default a) (nrepl-make-repl-connection-default b) @@ -239,9 +240,46 @@ (nrepl-connection-buffers))) (should (equal (buffer-name b) (nrepl-current-connection-buffer)))))) +(ert-deftest test-nrepl-rotate-connecton-buffer () + (noflet ((nrepl-current-connection-info ())) + (nrepl-test-with-buffers + (a b c) + (let ((nrepl-connection-list + (list (buffer-name a) (buffer-name b) (buffer-name c)))) + (should (equal (buffer-name a) (nrepl-current-connection-buffer))) + (nrepl-rotate-connection) + (should (equal (buffer-name b) (nrepl-current-connection-buffer))) + (nrepl-rotate-connection) + (should (equal (buffer-name c) (nrepl-current-connection-buffer))) + (nrepl-rotate-connection) + (should (equal (buffer-name a) (nrepl-current-connection-buffer))))))) + +(ert-deftest test-nrepl-current-connection-info () + (with-temp-buffer + (message (buffer-name (current-buffer))) + (let ((nrepl-connection-list (list (buffer-name (current-buffer))))) + (noflet ((message (m) + (when (string-match "Active nrepl connection" m) + (should (equal "Active nrepl connection: proj:somens, localhost:4005" m))))) + (set (make-local-variable 'nrepl-endpoint) '("localhost" 4005)) + (set (make-local-variable 'nrepl-project-dir) "proj") + (set (make-local-variable 'nrepl-buffer-ns) "somens") + (nrepl-current-connection-info))))) + +(ert-deftest test-nrepl-current-connection-info-no-project () + (with-temp-buffer + (message (buffer-name (current-buffer))) + (let ((nrepl-connection-list (list (buffer-name (current-buffer))))) + (noflet ((message (m) + (when (string-match "Active nrepl connection" m) + (should (equal "Active nrepl connection: <no project>:somens, localhost:4005" m))))) + (set (make-local-variable 'nrepl-endpoint) '("localhost" 4005)) + (set (make-local-variable 'nrepl-buffer-ns) "somens") + (nrepl-current-connection-info))))) + (ert-deftest test-nrepl-close () (lexical-let ((connections (nrepl-connection-buffers))) - (nrepl-test-with-two-buffers + (nrepl-test-with-buffers (a b) (nrepl-make-repl-connection-default a) (nrepl-make-repl-connection-default b) |