From 068b6f9797ac6b97c8e5d8c8b7ea2b18af487223 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Som=C4=93=20Cho?= Date: Sun, 2 Jul 2023 13:29:45 +0200 Subject: [PATCH] add test for resolver namespace --- .github/workflows/tests.yml | 3 +++ test/depo/resolver_test.clj | 49 +++++++++++++++++++++++++++++++++++++ tests.edn | 3 +++ 3 files changed, 55 insertions(+) create mode 100644 test/depo/resolver_test.clj diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 7cc8ce3..67efc51 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -25,3 +25,6 @@ jobs: - name: Run Unit Tests run: clojure -M:test "$@" unit + + - name: Test Resolver + run: clojure -M:test "$@" resolver diff --git a/test/depo/resolver_test.clj b/test/depo/resolver_test.clj new file mode 100644 index 0000000..51bb803 --- /dev/null +++ b/test/depo/resolver_test.clj @@ -0,0 +1,49 @@ +(ns depo.resolver-test + (:require [clojure.test :refer [testing deftest is]] + [malli.core :as m] + [depo.resolver :as r])) + +(deftest form-path + (testing "org.clojure/clojure" + (is (= "org/clojure/clojure" + (r/form-path {:groupID "org.clojure" + :artifactID "clojure"})))) + (testing "org.clojars.some/depo" + (is (= "org/clojars/some/depo" + (r/form-path {:groupID "org.clojars.some" + :artifactID "depo"})))) + (testing "reagent/reagent" + (is (= "reagent/reagent" + (r/form-path {:groupID "reagent" + :artifactID "reagent"})))) + (testing "reagent/reagent@1.2.0" + (is (= "reagent/reagent" + (r/form-path {:groupID "reagent" + :artifactID "reagent" + :version "1.2.0"}))))) + +(deftest conform-version + (testing "reagent" + (let [result (r/conform-version "reagent")] + (is (m/validate [:map + {:closed true} + [:groupID :string] + [:artifactID :string] + [:version :string]] result)))) + (testing "org.clojure/clojure" + (let [result (r/conform-version "org.clojure/clojure")] + (is (m/validate [:map + {:closed true} + [:groupID :string] + [:artifactID :string] + [:version :string]] result)))) + (testing "reagent@1.2.0" + (let [result (r/conform-version "reagent@1.2.0")] + (is (m/validate [:map + {:closed true} + [:groupID :string] + [:artifactID :string] + [:version [:= "1.2.0"]]] result)))) + (testing "reagent@1.2.0!!!" + (is (nil? (r/conform-version "reagent@1.2.0!!!"))))) + diff --git a/tests.edn b/tests.edn index 5113585..c26e02f 100644 --- a/tests.edn +++ b/tests.edn @@ -3,4 +3,7 @@ :plugins [:kaocha.plugin/profiling] :tests [{:id :unit :ns-patterns [".*-unit-test"] + :test-paths ["test" "src"]} + {:id :resolver + :ns-patterns [".resolver-test"] :test-paths ["test" "src"]}]}