Skip to content

Commit 44657e6

Browse files
committed
test: Add test for elin.component.nrepl
1 parent 8db0163 commit 44657e6

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

test/elin/component/nrepl_test.clj

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
(ns elin.component.nrepl-test
2+
(:require
3+
[clojure.core.async :as async]
4+
[clojure.test :as t]
5+
[com.stuartsierra.component :as component]
6+
[elin.component.nrepl]
7+
[elin.protocol.nrepl :as e.p.nrepl]
8+
[elin.system :as e.system]
9+
[elin.test-helper :as h]))
10+
11+
(t/use-fixtures :once h/malli-instrument-fixture)
12+
(t/use-fixtures :each h/test-nrepl-server-port-fixture)
13+
14+
(t/deftest new-nrepl-test
15+
(let [{:as sys :keys [nrepl]} (-> (e.system/new-system)
16+
(select-keys [:interceptor :nrepl])
17+
(component/start-system))]
18+
(try
19+
(t/is (nil? (e.p.nrepl/current-client nrepl)))
20+
21+
(let [client (e.p.nrepl/add-client! nrepl "localhost" h/*nrepl-server-port*)]
22+
(t/is (true? (e.p.nrepl/switch-client! nrepl client)))
23+
(t/is (= client (e.p.nrepl/current-client nrepl)))
24+
(t/is (= {:status ["done"]
25+
:session (:session client)
26+
:value "6"}
27+
(-> (e.p.nrepl/eval-op nrepl "(+ 1 2 3)" {})
28+
(async/<!!)
29+
(select-keys [:status :session :value]))))
30+
(t/is (= [(:session client)]
31+
(async/<!! (e.p.nrepl/ls-sessions nrepl)))))
32+
33+
(finally
34+
(component/stop-system sys)))))

0 commit comments

Comments
 (0)