diff --git a/deps.edn b/deps.edn index f7c00f52..b0e78752 100644 --- a/deps.edn +++ b/deps.edn @@ -40,7 +40,7 @@ borkdude/spartan.spec {:git/url "https://github.com/borkdude/spartan.spec" :sha "16f7eec4b6589c77c96c9fcf989f78fffcee7c4c"} lambdaisland/regal {:git/url "https://github.com/lambdaisland/regal" - :sha "b059fdb06d5586a9a04c27e7b011c467ad8546db"} + :sha "f902d2c43121f9e1c48603d6eb99f5900eb6a9f6"} weavejester/medley {:git/url "https://github.com/weavejester/medley" :sha "a4e5fb5383f5c0d83cb2d005181a35b76d8a136d"} babashka/babasha.curl {:local/root "babashka.curl"} diff --git a/test-resources/lib_tests/babashka/curl_test.clj b/test-resources/lib_tests/babashka/curl_test.clj new file mode 100644 index 00000000..856644c4 --- /dev/null +++ b/test-resources/lib_tests/babashka/curl_test.clj @@ -0,0 +1,25 @@ +(ns babashka.curl-test + (:require [babashka.curl :as curl] + [cheshire.core :as json] + [clojure.test :as t :refer [deftest]])) + +(deftest curl-test + (require '[babashka.curl :as curl] :reload-all) + + (prn (:status (curl/get "https://www.clojure.org"))) + + (prn (:status (curl/get "https://postman-echo.com/get?foo1=bar1&foo2=bar2"))) + + (prn (:status (curl/post "https://postman-echo.com/post"))) + + (prn (:status (curl/post "https://postman-echo.com/post" + {:body (json/generate-string {:a 1}) + :headers {"X-Hasura-Role" "admin"} + :content-type :json + :accept :json}))) + + (prn (:status (curl/put "https://postman-echo.com/put" + {:body (json/generate-string {:a 1}) + :headers {"X-Hasura-Role" "admin"} + :content-type :json + :accept :json})))) diff --git a/test-resources/lib_tests/babashka/lambdaisland/regal_test.clj b/test-resources/lib_tests/babashka/lambdaisland/regal_test.clj new file mode 100644 index 00000000..7f2fcf60 --- /dev/null +++ b/test-resources/lib_tests/babashka/lambdaisland/regal_test.clj @@ -0,0 +1,15 @@ +(ns babashka.lambdaisland.regal-test + (:require [clojure.test :as t :refer [deftest is]])) + +(prn :requiring :lambdaisland) +(require '[lambdaisland.regal :as regal]) +(prn ::done :requiring :lambdaisland) + +(def r [:cat + [:+ [:class [\a \z]]] + "=" + [:+ [:not \=]]]) + +(deftest regal-test + (is (= "[a-z]+=[^=]+" (str (regal/regex r)))) + (is (= "foo=bar" (re-matches (regal/regex r) "foo=bar")))) diff --git a/test-resources/lib_tests/babashka/run_all_libtests.clj b/test-resources/lib_tests/babashka/run_all_libtests.clj index 44860a69..1a544d56 100644 --- a/test-resources/lib_tests/babashka/run_all_libtests.clj +++ b/test-resources/lib_tests/babashka/run_all_libtests.clj @@ -8,57 +8,26 @@ (defn test-namespaces [& namespaces] (let [namespaces (if (seq ns-args) - (keep ns-args namespaces) + (seq (keep ns-args namespaces)) namespaces)] - (prn namespaces) - (doseq [ns namespaces] - (require ns)) - (let [m (apply t/run-tests namespaces)] - (swap! status (fn [status] - (merge-with + status (dissoc m :type))))))) + (when namespaces + (doseq [ns namespaces] + (require ns)) + (let [m (apply t/run-tests namespaces)] + (swap! status (fn [status] + (merge-with + status (dissoc m :type)))))))) ;;;; clj-http-lite -(require '[clj-http.lite.client :as client]) -(require '[cheshire.core :as json]) - -(prn (:status (client/get "https://www.clojure.org" {:throw-exceptions false}))) - -(prn (:status (client/get "https://postman-echo.com/get?foo1=bar1&foo2=bar2" {:throw-exceptions false}))) - -(prn (:status (client/post "https://postman-echo.com/post" {:throw-exceptions false}))) - -(prn (:status (client/post "https://postman-echo.com/post" - {:body (json/generate-string {:a 1}) - :headers {"X-Hasura-Role" "admin"} - :content-type :json - :accept :json - :throw-exceptions false}))) - -(prn (:status (client/put "https://postman-echo.com/put" - {:body (json/generate-string {:a 1}) - :headers {"X-Hasura-Role" "admin"} - :content-type :json - :accept :json - :throw-exceptions false}))) +(test-namespaces 'clj-http.lite.client-test) ;;;; spartan.spec -(time (require '[spartan.spec :as s])) -(require '[spartan.spec :as s]) -(time (s/explain (s/cat :i int? :s string?) [1 :foo])) -(time (s/conform (s/cat :i int? :s string?) [1 "foo"])) +(test-namespaces 'spartan.spec-test) ;;;; regal -(require '[lambdaisland.regal :as regal]) -(def r [:cat - [:+ [:class [\a \z]]] - "=" - [:+ [:not \=]]]) - -(prn (regal/regex r)) -(prn (re-matches (regal/regex r) "foo=bar")) +(test-namespaces 'babashka.lambdaisland.regal-test) ;;;; medley @@ -68,35 +37,20 @@ ;;;; babashka.curl -(require '[babashka.curl :as curl] :reload-all) - -(prn (:status (curl/get "https://www.clojure.org"))) - -(prn (:status (curl/get "https://postman-echo.com/get?foo1=bar1&foo2=bar2"))) - -(prn (:status (curl/post "https://postman-echo.com/post"))) - -(prn (:status (curl/post "https://postman-echo.com/post" - {:body (json/generate-string {:a 1}) - :headers {"X-Hasura-Role" "admin"} - :content-type :json - :accept :json}))) - -(prn (:status (curl/put "https://postman-echo.com/put" - {:body (json/generate-string {:a 1}) - :headers {"X-Hasura-Role" "admin"} - :content-type :json - :accept :json}))) - +(test-namespaces 'babashka.curl-test) ;;;; cprop +;; TODO: port to test-namespaces + (require '[cprop.core]) (require '[cprop.source :refer [from-env]]) (println (:cprop-env (from-env))) ;;;; comb +;; TODO: port to test-namespaces + (require '[comb.template :as template]) (prn (template/eval "<% (dotimes [x 3] %>foo<% ) %>")) (prn (template/eval "Hello <%= name %>" {:name "Alice"})) @@ -106,6 +60,8 @@ ;;;; arrangement +;; TODO: port to test-namespaces + (require '[arrangement.core :as order]) (prn (sort order/rank ['a false 2 :b nil 3.14159 "c" true \d [3 2] #{:one :two} @@ -117,12 +73,16 @@ ;;;; clojure-csv +;; TODO: port to test-namespaces + (require '[clojure-csv.core :as csv]) ;; TODO: convert to test (prn (csv/write-csv (csv/parse-csv "a,b,c\n1,2,3"))) ;;;; clojure.data.zip +;; TODO: port to test-namespaces + (require '[clojure.data.xml :as xml]) (require '[clojure.zip :as zip]) (require '[clojure.data.zip.xml :refer [attr attr= xml1->]]) @@ -148,6 +108,9 @@ ;;;; deps.clj +;; TODO: port to test-namespaces + +(require '[babashka.curl :as curl]) (spit "deps_test.clj" (:body (curl/get "https://raw.githubusercontent.com/borkdude/deps.clj/master/deps.clj"))) diff --git a/test-resources/lib_tests/clj_http/lite/client_test.clj b/test-resources/lib_tests/clj_http/lite/client_test.clj new file mode 100644 index 00000000..d61114c6 --- /dev/null +++ b/test-resources/lib_tests/clj_http/lite/client_test.clj @@ -0,0 +1,25 @@ +(ns clj-http.lite.client-test + (:require [cheshire.core :as json] + [clj-http.lite.client :as client] + [clojure.test :as t :refer [deftest]])) + +(deftest client-test + (prn (:status (client/get "https://www.clojure.org" {:throw-exceptions false}))) + + (prn (:status (client/get "https://postman-echo.com/get?foo1=bar1&foo2=bar2" {:throw-exceptions false}))) + + (prn (:status (client/post "https://postman-echo.com/post" {:throw-exceptions false}))) + + (prn (:status (client/post "https://postman-echo.com/post" + {:body (json/generate-string {:a 1}) + :headers {"X-Hasura-Role" "admin"} + :content-type :json + :accept :json + :throw-exceptions false}))) + + (prn (:status (client/put "https://postman-echo.com/put" + {:body (json/generate-string {:a 1}) + :headers {"X-Hasura-Role" "admin"} + :content-type :json + :accept :json + :throw-exceptions false})))) diff --git a/test-resources/lib_tests/spartan/spec_test.clj b/test-resources/lib_tests/spartan/spec_test.clj new file mode 100644 index 00000000..e08e02b1 --- /dev/null +++ b/test-resources/lib_tests/spartan/spec_test.clj @@ -0,0 +1,10 @@ +(ns spartan.spec-test + (:require [clojure.test :as t :refer [deftest is]])) + +(time (require '[spartan.spec :as s])) +(require '[spartan.spec :as s]) + +(deftest spec-test + (time (s/explain (s/cat :i int? :s string?) [1 :foo])) + (is (time (s/conform (s/cat :i int? :s string?) [1 "foo"])))) +