Skip to content

Commit

Permalink
add test for resolver namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
somecho committed Jul 2, 2023
1 parent 87ebdd1 commit 068b6f9
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,6 @@ jobs:

- name: Run Unit Tests
run: clojure -M:test "$@" unit

- name: Test Resolver
run: clojure -M:test "$@" resolver
49 changes: 49 additions & 0 deletions test/depo/resolver_test.clj
Original file line number Diff line number Diff line change
@@ -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!!!")))))

3 changes: 3 additions & 0 deletions tests.edn
Original file line number Diff line number Diff line change
Expand Up @@ -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"]}]}

0 comments on commit 068b6f9

Please sign in to comment.