mirror of
https://github.com/metosin/reitit.git
synced 2025-12-23 18:41:11 +00:00
Fix tests
This commit is contained in:
parent
16b6b8ad9f
commit
bc26eaed83
1 changed files with 10 additions and 11 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
(ns reitit.dependency-test
|
(ns reitit.dependency-test
|
||||||
(:require [clojure.test :refer :all]
|
(:require [clojure.test :refer [deftest testing is are]]
|
||||||
[reitit.dependency :refer [post-order]])
|
[reitit.dependency :as rc])
|
||||||
#?(:clj (:import [clojure.lang ExceptionInfo])))
|
#?(:clj (:import [clojure.lang ExceptionInfo])))
|
||||||
|
|
||||||
(deftest post-order-test
|
(deftest post-order-test
|
||||||
|
|
@ -9,26 +9,25 @@
|
||||||
{:name ::foo, :provides #{:foo}, :requires #{}, :wrap identity}]]
|
{:name ::foo, :provides #{:foo}, :requires #{}, :wrap identity}]]
|
||||||
(testing "happy cases"
|
(testing "happy cases"
|
||||||
(testing "default ordering works"
|
(testing "default ordering works"
|
||||||
(is (= (post-order base-middlewares)
|
(is (= (rc/post-order base-middlewares)
|
||||||
(into (vec (drop 2 base-middlewares)) (take 2 base-middlewares)))))
|
(into (vec (drop 2 base-middlewares)) (take 2 base-middlewares)))))
|
||||||
|
|
||||||
(testing "custom provides and requires work"
|
(testing "custom provides and requires work"
|
||||||
(is (= (post-order (comp hash-set :name)
|
(is (= (rc/post-order (comp hash-set :name)
|
||||||
(fn [node
|
(fn [node] (into #{} (map (fn [k] (keyword "reitit.dependency-test" (name k))))
|
||||||
](into #{} (map (fn [k] (keyword "reitit.dependency-test" (name k))))
|
(:requires node)))
|
||||||
(:requires node)))
|
base-middlewares)
|
||||||
base-middlewares)
|
|
||||||
(into (vec (drop 2 base-middlewares)) (take 2 base-middlewares))))))
|
(into (vec (drop 2 base-middlewares)) (take 2 base-middlewares))))))
|
||||||
|
|
||||||
(testing "errors"
|
(testing "errors"
|
||||||
(testing "missing dependency detection"
|
(testing "missing dependency detection"
|
||||||
(is (thrown-with-msg? ExceptionInfo #"missing"
|
(is (thrown-with-msg? ExceptionInfo #"missing"
|
||||||
(post-order (drop 1 base-middlewares)))))
|
(rc/post-order (drop 1 base-middlewares)))))
|
||||||
|
|
||||||
(testing "ambiguous dependency detection"
|
(testing "ambiguous dependency detection"
|
||||||
(is (thrown-with-msg? ExceptionInfo #"multiple providers"
|
(is (thrown-with-msg? ExceptionInfo #"multiple providers"
|
||||||
(post-order (update-in base-middlewares [0 :provides] conj :foo)))))
|
(rc/post-order (update-in base-middlewares [0 :provides] conj :foo)))))
|
||||||
|
|
||||||
(testing "circular dependency detection"
|
(testing "circular dependency detection"
|
||||||
(is (thrown-with-msg? ExceptionInfo #"circular"
|
(is (thrown-with-msg? ExceptionInfo #"circular"
|
||||||
(post-order (assoc-in base-middlewares [2 :requires] #{:baz}))))))))
|
(rc/post-order (assoc-in base-middlewares [2 :requires] #{:baz}))))))))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue