From 2787f8959f1d4a4613eb81d0d93c327c59b05616 Mon Sep 17 00:00:00 2001 From: John Wiseman Date: Mon, 12 Oct 2020 12:51:23 -0700 Subject: [PATCH] Added validate-config tests. --- .../lemondronor/advisorycircular_test.cljs | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/src/test/lemondronor/advisorycircular_test.cljs b/src/test/lemondronor/advisorycircular_test.cljs index c80cb1e..87d79e5 100644 --- a/src/test/lemondronor/advisorycircular_test.cljs +++ b/src/test/lemondronor/advisorycircular_test.cljs @@ -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"]})))))