Don't die on an empty config.yaml.

This commit is contained in:
John Wiseman 2020-01-20 21:44:29 -08:00
parent 074f7c77c3
commit 4c230226bb
4 changed files with 11 additions and 8 deletions

View File

@ -481,7 +481,7 @@
(defn build-config [config cli-config secrets]
(util/deep-merge default-config config cli-config secrets))
(util/deep-merge default-config oconfig cli-config secrets))
(defn main [& args]
(-> commander
@ -501,9 +501,6 @@
cli-config (build-config-from-commander commander)
secrets (util/read-config (.-secrets commander))
config (build-config base-config cli-config secrets)
_1 (pprint/pprint base-config)
_2 (pprint/pprint cli-config)
_3 (pprint/pprint config)
db (read-history-db (:history-db-path config))
data (get-adsbexchange-live-data
{:url (get-in config [:adsbx :url])

View File

@ -30,8 +30,9 @@
(defn read-config [path]
(log-verbose "Reading config file %s" path)
(p/let [data (read-file path {:encoding "utf-8"})]
(-> (yaml/safeLoad data)
(js->clj :keywordize-keys true))))
(let [config (-> (yaml/safeLoad data)
(js->clj :keywordize-keys true))]
(or config {}))))
;; Fetches a URL. Returns a promise that resolves to the body of the

View File

@ -7,4 +7,9 @@
{:adsbx {:url "http://bar"}}
{:adsbx {:url "http://foo"}}
{:adsbx {:secret "123"}})
{:adsbx {:url "http://foo", :secret "123"}})))
{:adsbx {:url "http://foo", :secret "123"}}))
(is (= (util/deep-merge
{:adsbx {:url "http://bar"}}
{}
{:adsbx {:secret "123"}})
{:adsbx {:url "http://bar", :secret "123"}})))

View File

@ -37,7 +37,7 @@
(deftest prune-history
(let [hist [{:time 0 :id 0} {:time 1000000 :id 1} {:time 2000000 :id 2}]]
(is (= (circlebot/prune-history hist 2500000)
(is (= (circlebot/prune-history hist 2500000 circlebot/default-config)
[{:time 2000000 :id 2}]))))