-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.sh
executable file
·68 lines (55 loc) · 2.04 KB
/
test.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/usr/bin/env bats
set -e
source ./version.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" ]
}
@test "Version on first commit default branch" {
result=$(_calculate_version "master" "vskd341" "0" "0" "master")
[ "$result" == "0.0.0" ]
}
@test "Version on second commit default branch" {
result=$(_calculate_version "master" "0.0.2" "0" "0" "master")
[ "$result" == "0.0.2" ]
}
@test "Version on fifth commit default branch" {
result=$(_calculate_version "master" "0.0.6" "0" "0" "master")
[ "$result" == "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" ]
}
@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" ]
}
@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" ]
}
@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" ]
}
@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" ]
}
@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" ]
}
@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" ]
}
@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" ]
}