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"]})))))