-
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.
- Loading branch information
1 parent
47bef9b
commit 4e23fb9
Showing
3 changed files
with
82 additions
and
95 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,57 +1,68 @@ | ||
#!/usr/bin/env bash | ||
source /work/version.sh | ||
#!/usr/bin/env bats | ||
set -e | ||
source ./version.sh | ||
|
||
source critic.sh | ||
@test "addition using bc" { | ||
result="$(echo 2+2 | bc)" | ||
[ "$result" -eq 4 ] | ||
} | ||
|
||
@test "Version if not git repo" { | ||
result=$(semver "1") | ||
[ "$result" == "1.0.0-SNAPSHOT" ] | ||
} | ||
|
||
_describe "Version if not git repo" | ||
_test "Should be 1.0.0-SNAPSHOT" semver "1" | ||
_assert _output_equals "1.0.0-SNAPSHOT" | ||
@test "Version on first commit default branch" { | ||
result=$(_calculate_version "master" "vskd341" "0" "0" "master") | ||
[ "$result" == "0.0.0" ] | ||
} | ||
|
||
_describe "Version on first commit default branch" | ||
_test "Should be 0.0.0" calculate_version "master" "vskd341" "0" "0" "master" | ||
_assert _output_equals "0.0.0" | ||
@test "Version on second commit default branch" { | ||
result=$(_calculate_version "master" "0.0.2" "0" "0" "master") | ||
[ "$result" == "0.0.2" ] | ||
} | ||
|
||
_describe "Version on second commit default branch" | ||
_test "Should be 0.0.2" calculate_version "master" "0.0.2" "0" "0" "master" | ||
_assert _output_equals "0.0.2" | ||
@test "Version on fifth commit default branch" { | ||
result=$(_calculate_version "master" "0.0.6" "0" "0" "master") | ||
[ "$result" == "0.0.6" ] | ||
} | ||
|
||
_describe "Version on fifth commit default branch" | ||
_test "Should be 0.0.6" calculate_version "master" "0.0.6" "0" "0" "master" | ||
_assert _output_equals "0.0.6" | ||
@test "Version on with different minor on default branch" { | ||
result=$(_calculate_version "master" "0.0.1-5-aaghas27" "0" "1" "master") | ||
[ "$result" == "0.1.0" ] | ||
} | ||
|
||
_describe "Version on with different minor on default branch" | ||
_test "Should be 0.1.0" calculate_version "master" "0.0.1-5-aaghas27" "0" "1" "master" | ||
_assert _output_equals "0.1.0" | ||
@test "Version on with different major on default branch" { | ||
result=$(_calculate_version "master" "0.0.1-5-aaghas27" "1" "0" "master") | ||
[ "$result" == "1.0.0" ] | ||
} | ||
|
||
_describe "Version on with different major on default branch" | ||
_test "Should be 1.0.0" calculate_version "master" "0.0.1-5-aaghas27" "1" "0" "master" | ||
_assert _output_equals "1.0.0" | ||
@test "Version on with different major and minor on default branch" { | ||
result=$(_calculate_version "master" "0.0.1-5-aaghas27" "1" "1" "master") | ||
[ "$result" == "1.1.0" ] | ||
} | ||
|
||
_describe "Version on with different major and minor on default branch" | ||
_test "Should be 1.1.0" calculate_version "master" "0.0.1-5-aaghas27" "1" "1" "master" | ||
_assert _output_equals "1.1.0" | ||
@test "Version on second commit on feature branch" { | ||
result=$(_calculate_version "feature" "0.0.1-1-aaghas27" "0" "0" "master") | ||
[ "$result" == "0.0.1-1-aaghas27-feature" ] | ||
} | ||
|
||
_describe "Version on second commit on feature branch" | ||
_test "Should be 0.0.1-1-aaghas27-feature" calculate_version "feature" "0.0.1-1-aaghas27" "0" "0" "master" | ||
_assert _output_equals "0.0.1-1-aaghas27-feature" | ||
@test "Version on fifth commit on feature branch" { | ||
result=$(_calculate_version "feature" "0.0.1-5-aaghas27" "0" "0" "master") | ||
[ "$result" == "0.0.1-5-aaghas27-feature" ] | ||
} | ||
|
||
_describe "Version on fifth commit on feature branch" | ||
_test "Should be 0.0.1-5-aaghas27-feature" calculate_version "feature" "0.0.1-5-aaghas27" "0" "0" "master" | ||
_assert _output_equals "0.0.1-5-aaghas27-feature" | ||
@test "Version on feature branch with different minor" { | ||
result=$(_calculate_version "feature" "0.0.1-5-aaghas27" "0" "1" "master") | ||
[ "$result" == "0.0.1-5-aaghas27-feature" ] | ||
} | ||
|
||
_describe "Version on feature branch with different minor" | ||
_test "Should be 0.0.1-5-aaghas27-feature" calculate_version "feature" "0.0.1-5-aaghas27" "0" "1" "master" | ||
_assert _output_equals "0.0.1-5-aaghas27-feature" | ||
@test "Version on feature branch with different major" { | ||
result=$(_calculate_version "feature" "0.0.1-5-aaghas27" "1" "0" "master") | ||
[ "$result" == "0.0.1-5-aaghas27-feature" ] | ||
} | ||
|
||
_describe "Version on feature branch with different major" | ||
_test "Should be 0.0.1-5-aaghas27-feature" calculate_version "feature" "0.0.1-5-aaghas27" "1" "0" "master" | ||
_assert _output_equals "0.0.1-5-aaghas27-feature" | ||
|
||
_describe "Version on feature branch with different major and minor" | ||
_test "Should be 0.0.1-5-aaghas27-feature" calculate_version "feature" "0.0.1-5-aaghas27" "1" "1" "master" | ||
_assert _output_equals "0.0.1-5-aaghas27-feature" | ||
|
||
_describe "Version on default branch even if tag starts with v" | ||
_test "Should be 0.0.2" calculate_version "master" "0.0.2" "0" "0" "master" | ||
_assert _output_equals "0.0.2" | ||
@test "Version on feature branch with different major and minor" { | ||
result=$(_calculate_version "feature" "0.0.1-5-aaghas27" "1" "1" "master") | ||
[ "$result" == "0.0.1-5-aaghas27-feature" ] | ||
} |
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