Skip to content

Commit

Permalink
make sure clj test process shuts down
Browse files Browse the repository at this point in the history
  • Loading branch information
raystubbs committed Aug 25, 2024
1 parent df7bd59 commit 366cb56
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions test/cljc/zero/core_test.cljc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(ns zero.core-test
(:require
[zero.core :refer [<< <<act <<ctx <<<] :as z]
#?(:clj [clojure.test :refer [deftest is]]
#?(:clj [clojure.test :refer [deftest is use-fixtures]]
:cljs [cljs.test :refer-macros [deftest is]])))

(deftest injector-construction
Expand All @@ -10,23 +10,33 @@
(is (= ::k1 key))
(is (= (list ::arg1 ::arg2) (take 2 args)))
(is (z/inj? (last args)))

(let [{inner-args :args inner-key :key} (z/inj->map (last args))]
(is (= ::k2 inner-key))
(is (= (list ::arg3) inner-args))))
(let [inj (<< ::k1 <<ctx ::k2 <<act ::k3 <<< ::k4)
{:keys [args key]} (z/inj->map inj)]
(is (= ::k1 key))
(is (z/inj? (last args)))

(let [{inner-args :args inner-key :key} (z/inj->map (last args))]
(is (= ::z/ctx inner-key))
(is (z/inj? (last inner-args)))

(let [{inner-args-2 :args inner-key-2 :key} (z/inj->map (last inner-args))]
(is (= ::z/act inner-key-2))
(is (z/inj? (last inner-args-2)))

(let [{inner-args-3 :args inner-key-3 :key} (z/inj->map (last inner-args-2))]
(is (= ::z/<< inner-key-3))
(is (= ::k4 (last inner-args-3))))))))

;; timers, agents, etc will prevent the test process from finishing/closing
#?(:clj
(use-fixtures
:once
(fn [f]
(f)
(future
(Thread/sleep 1000)
(System/exit 0)))))

0 comments on commit 366cb56

Please sign in to comment.