Skip to content

Commit

Permalink
fix: Fix boot upgrader to be able to handle meta
Browse files Browse the repository at this point in the history
cf. #189
  • Loading branch information
liquidz committed Nov 16, 2022
1 parent ac36445 commit ef3f1c4
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 4 deletions.
7 changes: 5 additions & 2 deletions src/antq/upgrade/boot.clj
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@

(defn- in-dependencies?
[loc]
(-> loc z/up z/up z/up z/left z/sexpr
(= :dependencies)))
(loop [loc (-> loc z/up z/up)]
(case (z/tag loc)
:meta (recur (z/up loc))
:vector (= :dependencies (-> loc z/up z/left z/sexpr))
false)))

(defn upgrade-dep
[loc version-checked-dep]
Expand Down
3 changes: 2 additions & 1 deletion test/antq/dep/boot_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
(t/is (every? #(instance? antq.record.Dependency %) deps))
(t/is (= #{(dependency {:name "foo/core" :version "1.0.0"})
(dependency {:name "bar/bar" :version "2.0.0"})
(dependency {:name "baz/baz" :version "3.0.0"})}
(dependency {:name "baz/baz" :version "3.0.0"})
(dependency {:name "with/meta" :version "4.0.0"})}
(set deps)))))

(t/deftest load-deps-test
Expand Down
18 changes: 18 additions & 0 deletions test/antq/upgrade/boot_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@
:latest-version "9.0.0"
:file (io/resource "dep/test_build.boot")}))

(def ^:private dummy-meta-dep
(r/map->Dependency {:project :boot
:type :java
:name "with/meta"
:latest-version "9.0.0"
:file (io/resource "dep/test_build.boot")}))

(t/deftest upgrade-dep-test
(let [from-deps (->> dummy-java-dep
:file
Expand All @@ -25,3 +32,14 @@
(dep.boot/extract-deps ""))]
(t/is (= #{{:name "bar/bar" :version {:- "2.0.0" :+ "9.0.0"}}}
(h/diff-deps from-deps to-deps)))))

(t/deftest upgrade-meta-dep-test
(let [from-deps (->> dummy-meta-dep
:file
(slurp)
(dep.boot/extract-deps ""))
to-deps (->> dummy-meta-dep
(upgrade/upgrader)
(dep.boot/extract-deps ""))]
(t/is (= #{{:name "with/meta" :version {:- "4.0.0" :+ "9.0.0"}}}
(h/diff-deps from-deps to-deps)))))
1 change: 1 addition & 0 deletions test/resources/dep/test_build.boot
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
:dependencies '[[foo/core "1.0.0"]
[bar "2.0.0"]
[baz "3.0.0" :scope "test"]
^:foo/bar [with/meta "4.0.0"]
[ver-not-string :version]
[ver-empty ""]])

Expand Down
3 changes: 2 additions & 1 deletion tests.edn
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#kaocha/v1
{:color? true
:reporter [kaocha.report/dots]}
:reporter [kaocha.report/documentation]}
;:reporter [kaocha.report/dots]}

0 comments on commit ef3f1c4

Please sign in to comment.