Added failing test as template to fix "flatten-and-reduce-config"
This commit is contained in:
parent
ac2a4da7b4
commit
5bcfe9f0b1
2 changed files with 61 additions and 1 deletions
|
@ -12,8 +12,9 @@
|
|||
; There must be a check or the config must be sorted first!
|
||||
(defn flatten-and-reduce-config
|
||||
[config]
|
||||
(merge (-> config :websites first) (-> config :auth first) (dissoc config :issuer :volume-size)))
|
||||
(merge (-> config :websites first) (-> config :auth first) (dissoc config :websites :auth)))
|
||||
|
||||
; TODO: Find a better readable expression.
|
||||
(defn generate-configs [config]
|
||||
(loop [config config
|
||||
result []]
|
||||
|
|
59
src/test/cljc/dda/c4k_website/core_test.cljc
Normal file
59
src/test/cljc/dda/c4k_website/core_test.cljc
Normal file
|
@ -0,0 +1,59 @@
|
|||
(ns dda.c4k-website.core-test
|
||||
(:require
|
||||
#?(:clj [clojure.test :refer [deftest is are testing run-tests]]
|
||||
:cljs [cljs.test :refer-macros [deftest is are testing run-tests]])
|
||||
[clojure.spec.test.alpha :as st]
|
||||
[dda.c4k-common.test-helper :as th]
|
||||
[dda.c4k-common.base64 :as b64]
|
||||
[dda.c4k-website.core :as cut]
|
||||
[clojure.spec.alpha :as s]))
|
||||
|
||||
(def websites
|
||||
{:websites
|
||||
[{:unique-name "example.io"
|
||||
:fqdns ["example.org", "www.example.com"]
|
||||
:gitea-host "finegitehost.net"
|
||||
:gitea-repo "repo"
|
||||
:branchname "main"}
|
||||
{:unique-name "test.io"
|
||||
:fqdns ["test.de" "test.org" "www.test.de" "www.test.org"]
|
||||
:gitea-host "gitlab.de"
|
||||
:gitea-repo "repo"
|
||||
:branchname "main"}]})
|
||||
|
||||
(def auth1
|
||||
{:auth
|
||||
[{:unique-name "example.io"
|
||||
:username "someuser"
|
||||
:authtoken "abedjgbasdodj"}
|
||||
{:unique-name "test.io"
|
||||
:username "someuser"
|
||||
:authtoken "abedjgbasdodj"}]})
|
||||
|
||||
(def auth2
|
||||
{:auth
|
||||
[{:unique-name "test.io"
|
||||
:username "someuser"
|
||||
:authtoken "abedjgbasdodj"}
|
||||
{:unique-name "example.io"
|
||||
:username "someuser"
|
||||
:authtoken "abedjgbasdodj"}]})
|
||||
|
||||
(def flattened-and-reduced-config
|
||||
{:unique-name "example.io",
|
||||
:fqdns ["example.org" "www.example.com"],
|
||||
:gitea-host "finegitehost.net",
|
||||
:gitea-repo "repo",
|
||||
:branchname "main",
|
||||
:username "someuser",
|
||||
:authtoken "abedjgbasdodj"})
|
||||
|
||||
; TODO: gec 2022/10/28: This might be the desired behavior.
|
||||
; cut/flatten-and-reduce-config must be fixed accordingly.
|
||||
(deftest test-flatten-and-reduce-config
|
||||
(is (=
|
||||
(cut/flatten-and-reduce-config (merge websites auth1))
|
||||
flattened-and-reduced-config))
|
||||
(is (=
|
||||
(cut/flatten-and-reduce-config (merge websites auth2))
|
||||
flattened-and-reduced-config)))
|
Loading…
Reference in a new issue