diff --git a/src/main/cljc/dda/c4k_website/core.cljc b/src/main/cljc/dda/c4k_website/core.cljc index e11683f..d006161 100644 --- a/src/main/cljc/dda/c4k_website/core.cljc +++ b/src/main/cljc/dda/c4k_website/core.cljc @@ -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 []] diff --git a/src/test/cljc/dda/c4k_website/core_test.cljc b/src/test/cljc/dda/c4k_website/core_test.cljc new file mode 100644 index 0000000..dea9991 --- /dev/null +++ b/src/test/cljc/dda/c4k_website/core_test.cljc @@ -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))) \ No newline at end of file