Skip to content

Commit 94696f6

Browse files
arichiardimartinklepsch
authored andcommitted
Add tests for the parent tag feature
The patch also removes some obsolete file and hooks up boot/worker tests in Makefile.
1 parent e7898a9 commit 94696f6

File tree

4 files changed

+71
-7
lines changed

4 files changed

+71
-7
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ deploy: .deployed
9696

9797
.tested: bin/boot
9898
(export BOOT_VERSION=$(version) && export BOOT_EMIT_TARGET=no && cd boot/core && ../../bin/boot -x test)
99+
(export BOOT_VERSION=$(version) && export BOOT_EMIT_TARGET=no && cd boot/worker && ../../bin/boot -x test)
99100
(cd boot/pod && lein test)
100101
date > .tested
101102

boot/worker/build.boot

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
(set-env!
2+
:source-paths #{"src" "test"}
3+
:dependencies '[[net.cgrand/parsley "0.9.3" :exclusions [org.clojure/clojure]]
4+
[mvxcvi/puget "1.0.1"]
5+
[reply "0.3.7"]
6+
[cheshire "5.3.1"]
7+
[clj-jgit "0.8.0"]
8+
[clj-yaml "0.4.0"]
9+
[javazoom/jlayer "1.0.1"]
10+
[net.java.dev.jna/jna "4.1.0"]
11+
[alandipert/desiderata "1.0.2"]
12+
[org.clojure/data.xml "0.0.8"]
13+
[org.clojure/data.zip "0.1.1"]
14+
[org.clojure/tools.namespace "0.2.11"]
15+
16+
[metosin/boot-alt-test "0.3.2" :scope "test"]])
17+
18+
(ns-unmap 'boot.user 'test)
19+
20+
(require '[metosin.boot-alt-test :refer [alt-test]])
21+
22+
(import boot.App)
23+
24+
(deftask test []
25+
(comp
26+
(with-pass-thru [fs]
27+
(boot.util/info "Testing against version %s\n" (App/config "BOOT_VERSION")))
28+
(alt-test)))

boot/worker/test/boot/aether_test.clj

Lines changed: 0 additions & 7 deletions
This file was deleted.

boot/worker/test/boot/pom_test.clj

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
(ns boot.pom-test
2+
(:require [boot.pom :as pom]
3+
[clojure.test :as test :refer [deftest is testing]]
4+
[clojure.zip :as zip]
5+
[clojure.data.xml :as dxml]
6+
[clojure.data.zip.xml :as dzxml]))
7+
8+
(deftest pom-parent
9+
10+
(testing "pom-xml-parse-string"
11+
(let [xml-str "<project xmlns=\"http://maven.apache.org/POM/4.0.0\"\n xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0\n https://maven.apache.org/xsd/maven-4.0.0.xsd\">\n <modelVersion>4.0.0</modelVersion>\n \n <parent>\n <groupId>org.codehaus.mojo</groupId>\n <artifactId>my-parent</artifactId>\n <version>2.0</version>\n <relativePath>../my-parent</relativePath>\n </parent>\n \n <artifactId>my-project</artifactId>\n</project>\n"
12+
{:keys [parent]} (pom/pom-xml-parse-string xml-str)]
13+
(is (= '[org.codehaus.mojo/my-parent "2.0"] (:dependency parent)) "The parent :dependency must exist and match the example")
14+
(is (= "../my-parent" (:relative-path parent)) "The parent :relative-path key must exist and match the example"))
15+
16+
(let [xml-str "<project xmlns=\"http://maven.apache.org/POM/4.0.0\"\n xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0\n https://maven.apache.org/xsd/maven-4.0.0.xsd\">\n <modelVersion>4.0.0</modelVersion>\n \n <groupId>org.codehaus.mojo</groupId>\n <artifactId>my-parent</artifactId>\n <version>2.0</version>\n <packaging>pom</packaging>\n</project>"
17+
{:keys [parent]} (pom/pom-xml-parse-string xml-str)]
18+
(is (nil? parent) "The parent tag must not exist if missing in the pom"))
19+
20+
(let [xml-str "<project xmlns=\"http://maven.apache.org/POM/4.0.0\"\n xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0\n https://maven.apache.org/xsd/maven-4.0.0.xsd\">\n <modelVersion>4.0.0</modelVersion>\n \n <parent>\n <artifactId>my-parent</artifactId>\n <version>2.0</version>\n </parent>\n \n <artifactId>my-project</artifactId>\n</project>\n"
21+
{:keys [parent]} (pom/pom-xml-parse-string xml-str)]
22+
(is (= '[my-parent "2.0"] (-> :dependency parent)) "The parent :dependency must exist and be just the artifactId of the example")
23+
(is (nil? (-> parent :dependency first namespace)) "The parent :dependency must exist but should not have the groupId as per example")
24+
(is (nil? (:relative-path parent)) "The parent :relative-path must be nil as it is not in the example"))
25+
26+
;; Edge case - parent tag is there but does not have artifactId
27+
(let [xml-str "<project xmlns=\"http://maven.apache.org/POM/4.0.0\"\n xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0\n https://maven.apache.org/xsd/maven-4.0.0.xsd\">\n <modelVersion>4.0.0</modelVersion>\n \n <parent>\n <groupId>org.codehaus.mojo</groupId>\n </parent>\n \n <artifactId>my-project</artifactId>\n</project>\n"
28+
{:keys [parent]} (pom/pom-xml-parse-string xml-str)]
29+
(is (nil? (-> :dependency parent)) "The parent :dependency should be nil if no artifactId is there")))
30+
31+
(testing "pom-xml :parent"
32+
(let [parent-loc (-> {:project 'group/my-plugin
33+
:version "1.2.0"
34+
:parent '[org.codehaus.mojo/my-parent "2.0"]}
35+
pom/pom-xml
36+
pr-str
37+
dxml/parse-str
38+
zip/xml-zip
39+
(dzxml/xml1-> :parent))]
40+
(is (not (nil? (dzxml/xml1-> parent-loc :groupId "org.codehaus.mojo"))) "I should contain a :groupId tag with correct content")
41+
(is (not (nil? (dzxml/xml1-> parent-loc :artifactId "my-parent"))) "It should contain a :artifactId tag with correct content")
42+
(is (not (nil? (dzxml/xml1-> parent-loc :version "2.0"))) "It should contain a :version tag with correct content"))))

0 commit comments

Comments
 (0)