-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add default behaviour to bump version
- Loading branch information
1 parent
175f28f
commit 3c5a687
Showing
2 changed files
with
79 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,68 @@ | ||
(ns xdeps.api.version.semantic-test | ||
(:require | ||
[clojure.test :refer [deftest testing is]] | ||
[xdeps.api.version.semantic :as sut])) | ||
[clojure.test :refer [deftest is testing]] | ||
[xdeps.api.version.semantic :as sut])) | ||
|
||
|
||
(deftest parse-test | ||
(deftest ^:unit parse-test | ||
(testing "correct conversion to a string" | ||
(doseq [v ["0.1.0" | ||
"0.1.0-SNAPSHOT" | ||
"0.1.0+master-bb1023" | ||
"0.1.0-alpha+master-bb1023"]] | ||
(is (= v (str (sut/parse v))))))) | ||
|
||
|
||
(deftest bump-test | ||
(deftest ^:unit bump-test | ||
(testing "correct version bump" | ||
(testing "major version" | ||
(let [v (sut/bump "0.1.2" :major)] | ||
(is (= "1.0.0" (str v))) | ||
(is (= {:major 1, :minor 0, :patch 0, :pre-release nil, :build nil} | ||
(into {} v))))) | ||
|
||
(testing "minor version" | ||
(let [v (sut/bump "0.1.2" :minor)] | ||
(is (= "0.2.0" (str v))) | ||
(is (= {:major 0, :minor 2, :patch 0, :pre-release nil, :build nil} | ||
(into {} v))))) | ||
|
||
(testing "patch version" | ||
(let [v (sut/bump "0.1.2" :patch)] | ||
(is (= "0.1.3" (str v))) | ||
(is (= {:major 0, :minor 1, :patch 3, :pre-release nil, :build nil} | ||
(into {} v))))))) | ||
|
||
(testing "string -> string" | ||
(testing "major version" | ||
(is (= "1.0.0" (sut/bump "0.1.2" :major)))) | ||
|
||
(testing "minor version" | ||
(is (= "0.2.0" (sut/bump "0.1.2" :minor)))) | ||
|
||
(testing "patch version" | ||
(is (= "0.1.3" | ||
(sut/bump "0.1.2") | ||
(sut/bump "0.1.2" :patch))))) | ||
|
||
(testing "semantic version -> semantic version" | ||
(testing "major version" | ||
(let [v (-> "0.1.2" | ||
(sut/parse) | ||
(sut/bump :major))] | ||
(is (= "1.0.0" (str v))) | ||
(is (= {:major 1 | ||
:minor 0 | ||
:patch 0 | ||
:pre-release nil | ||
:build nil} | ||
(into {} v))))) | ||
|
||
(testing "minor version" | ||
(let [v (-> "0.1.2" | ||
(sut/parse) | ||
(sut/bump :minor))] | ||
(is (= "0.2.0" (str v))) | ||
(is (= {:major 0 | ||
:minor 2 | ||
:patch 0 | ||
:pre-release nil | ||
:build nil} | ||
(into {} v))))) | ||
|
||
(testing "patch version" | ||
(let [v1 (-> "0.1.2" | ||
(sut/parse) | ||
(sut/bump)) | ||
v2 (-> "0.1.2" | ||
(sut/parse) | ||
(sut/bump :patch))] | ||
(is (= "0.1.3" (str v1) (str v2))) | ||
(is (= {:major 0 | ||
:minor 1 | ||
:patch 3 | ||
:pre-release nil | ||
:build nil} | ||
(into {} v1) | ||
(into {} v2)))))))) |