Skip to content

Commit

Permalink
test: Add test for elin.component.nrepl
Browse files Browse the repository at this point in the history
  • Loading branch information
liquidz committed Jan 23, 2024
1 parent 8db0163 commit 44657e6
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions test/elin/component/nrepl_test.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
(ns elin.component.nrepl-test
(:require
[clojure.core.async :as async]
[clojure.test :as t]
[com.stuartsierra.component :as component]
[elin.component.nrepl]
[elin.protocol.nrepl :as e.p.nrepl]
[elin.system :as e.system]
[elin.test-helper :as h]))

(t/use-fixtures :once h/malli-instrument-fixture)
(t/use-fixtures :each h/test-nrepl-server-port-fixture)

(t/deftest new-nrepl-test
(let [{:as sys :keys [nrepl]} (-> (e.system/new-system)
(select-keys [:interceptor :nrepl])
(component/start-system))]
(try
(t/is (nil? (e.p.nrepl/current-client nrepl)))

(let [client (e.p.nrepl/add-client! nrepl "localhost" h/*nrepl-server-port*)]
(t/is (true? (e.p.nrepl/switch-client! nrepl client)))
(t/is (= client (e.p.nrepl/current-client nrepl)))
(t/is (= {:status ["done"]
:session (:session client)
:value "6"}
(-> (e.p.nrepl/eval-op nrepl "(+ 1 2 3)" {})
(async/<!!)
(select-keys [:status :session :value]))))
(t/is (= [(:session client)]
(async/<!! (e.p.nrepl/ls-sessions nrepl)))))

(finally
(component/stop-system sys)))))

0 comments on commit 44657e6

Please sign in to comment.