Added validate-config tests.

This commit is contained in:
John Wiseman 2020-10-12 12:51:23 -07:00
parent f601f272d4
commit 2787f8959f
1 changed files with 43 additions and 0 deletions

View File

@ -414,3 +414,46 @@
(p/let [r (advisorycircular/closest-airport conf 0 0)]
(is (= r a3)))))
(done)))))
(deftest validate-config
(testing "Good config w/ lat-lon-radius"
(advisorycircular/validate-config
{:adsbx {:api-key "my-adsbx-key"
:url "http://adsbx"}
:aircraft-info-db-path "/"
:pelias {:url "http://pelias/"}
:lat 0
:lon 1
:radius-km 5}))
(testing "Bad config missing radius"
(is (thrown-with-msg?
js/Error #"Missing configuration values.*radius"
(advisorycircular/validate-config
{:adsbx {:api-key "my-adsbx-key"
:url "http://adsbx"}
:aircraft-info-db-path "/"
:pelias {:url "http://pelias/"}
:lat 0
:lon 1}))))
(testing "Bad config missing everything"
(is (thrown-with-msg?
js/Error #"Missing configuration values.*adsbx"
(advisorycircular/validate-config {}))))
(testing "Bad config missing lat-lon-radius"
(is (thrown-with-msg?
js/Error #"Missing configuration values.*lat.*lon.*radius-km"
(advisorycircular/validate-config
{:adsbx {:api-key "my-adsbx-key"
:url "http://adsbx"}
:aircraft-info-db-path "/"
:pelias {:url "http://pelias/"}}))))
(testing "Bad config with icaos instead of lat/lon/radius"
(is (thrown-with-msg?
js/Error #"Missing configuration values.*lat.*lon.*radius-km"
(advisorycircular/validate-config
{:adsbx {:api-key "my-adsbx-key"
:url "http://adsbx"}
:aircraft-info-db-path "/"
:pelias {:url "http://pelias/"}
:icaos ["123" "456"]})))))