Fix bug
This commit is contained in:
parent
911f0d5b27
commit
75ef2572e3
2 changed files with 17 additions and 14 deletions
|
@ -13,23 +13,26 @@
|
||||||
|
|
||||||
(def merged-config-and-auth? (s/and website/config? website/auth?))
|
(def merged-config-and-auth? (s/and website/config? website/auth?))
|
||||||
|
|
||||||
(defn-spec flatten-and-reduce-config pred/map-or-seq?
|
(defn-spec sort-config pred/map-or-seq?
|
||||||
[unsorted-config merged-config-and-auth?]
|
[unsorted-config merged-config-and-auth?]
|
||||||
(let [sorted-websites (into [] (sort-by :unique-name (unsorted-config :websites)))
|
(let [sorted-websites (into [] (sort-by :unique-name (unsorted-config :websites)))
|
||||||
sorted-auth (into [] (sort-by :unique-name (unsorted-config :auth)))
|
sorted-auth (into [] (sort-by :unique-name (unsorted-config :auth)))]
|
||||||
config (-> unsorted-config
|
(-> unsorted-config
|
||||||
(assoc-in [:websites] sorted-websites)
|
(assoc-in [:websites] sorted-websites)
|
||||||
(assoc-in [:auth] sorted-auth))]
|
(assoc-in [:auth] sorted-auth))))
|
||||||
|
|
||||||
|
(defn-spec flatten-and-reduce-config pred/map-or-seq?
|
||||||
|
[config merged-config-and-auth?]
|
||||||
(merge (-> config :websites first)
|
(merge (-> config :websites first)
|
||||||
(-> config :auth first)
|
(-> config :auth first)
|
||||||
(when (contains? config :issuer)
|
(when (contains? config :issuer)
|
||||||
{:issuer (config :issuer)})
|
{:issuer (config :issuer)})
|
||||||
(when (contains? config :volume-size)
|
(when (contains? config :volume-size)
|
||||||
{:volume-size (config :volume-size)}))))
|
{:volume-size (config :volume-size)})))
|
||||||
|
|
||||||
; TODO: Find a better readable expression.
|
; TODO: Find a better readable expression.
|
||||||
(defn generate-configs [config]
|
(defn generate-configs [config]
|
||||||
(loop [config config
|
(loop [config (sort-config config)
|
||||||
result []]
|
result []]
|
||||||
|
|
||||||
(if (and (empty? (config :auth)) (empty? (config :websites)))
|
(if (and (empty? (config :auth)) (empty? (config :websites)))
|
||||||
|
|
|
@ -50,8 +50,8 @@
|
||||||
|
|
||||||
(deftest test-flatten-and-reduce-config
|
(deftest test-flatten-and-reduce-config
|
||||||
(is (=
|
(is (=
|
||||||
(cut/flatten-and-reduce-config (merge websites auth1))
|
(cut/flatten-and-reduce-config (cut/sort-config (merge websites auth1)))
|
||||||
flattened-and-reduced-config))
|
flattened-and-reduced-config))
|
||||||
(is (=
|
(is (=
|
||||||
(cut/flatten-and-reduce-config (merge websites auth2))
|
(cut/flatten-and-reduce-config (cut/sort-config (merge websites auth2)))
|
||||||
flattened-and-reduced-config)))
|
flattened-and-reduced-config)))
|
Loading…
Reference in a new issue