Account for repl urls with paths [fixes #1344, again]

This commit is contained in:
Toby Crawley 2013-10-17 00:06:40 -04:00
parent c4446fc531
commit 3e865aedf2
2 changed files with 15 additions and 11 deletions

View file

@ -48,7 +48,7 @@
port)))
(defn ensure-port [s]
(if (re-find #":\d+$" s)
(if (re-find #":\d+($|/.*$)" s)
s
(main/abort "Port is required. See `lein help repl`")))

View file

@ -70,22 +70,26 @@
(= exp (with-redefs [repl-host (constantly "repl-host")
repl-port (constantly 5)]
(connect-string {} [in])))
"" "repl-host:5"
"7" "repl-host:7"
"myhost:9" "myhost:9"
"http://localhost:20" "http://localhost:20")
"" "repl-host:5"
"7" "repl-host:7"
"myhost:9" "myhost:9"
"http://localhost:20" "http://localhost:20"
"http://localhost:20/ham" "http://localhost:20/ham")
(with-redefs [repl-host (constantly "repl-host")
repl-port (constantly 0)]
(is (= "repl-host:1" (connect-string {} ["1"])))
(is (= "repl-host:123" (connect-string {} ["123"])))
(is (re-find
#"Port is required"
(lthelper/abort-msg connect-string {} []))))
(are [in proj]
(is (re-find
#"Port is required"
(lthelper/abort-msg connect-string proj in)))
["http://localhost/ham"] {}
["foo1234"] {}
[] {}
[] lthelper/with-resources-project))
(is (= "127.0.0.1:4242" (connect-string lthelper/sample-project [])))
(is (= "127.0.0.1:4343" (connect-string lthelper/sample-project ["4343"])))
(is (re-find
#"Port is required"
(lthelper/abort-msg connect-string lthelper/with-resources-project [])))
(is (= "127.0.0.1:4242" (connect-string lthelper/with-resources-project ["4242"]))))
(deftest test-options-for-reply