-
Notifications
You must be signed in to change notification settings - Fork 22
/
common_tests.sh
executable file
·73 lines (62 loc) · 3 KB
/
common_tests.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
69
70
71
72
73
#!/usr/bin/env bash
SCRIPT_DIR="$(dirname "$(readlink -f "$0")")"
export USE_TEST_REPO=true
# Source the latest version of assert.sh unit testing library and include in current shell
assert_script_content=$(curl --silent https://raw.githubusercontent.com/hazelcast/assert.sh/main/assert.sh)
# shellcheck source=/dev/null
. <(echo "${assert_script_content}")
. "$SCRIPT_DIR"/common.sh
TESTS_RESULT=0
function assertReleaseType {
export HZ_VERSION=$1
local expected=$2
. "$SCRIPT_DIR"/common.sh
local msg="Version $HZ_VERSION should be a $expected release"
assert_eq $expected $RELEASE_TYPE "$msg" && log_success "$msg" || TESTS_RESULT=$?
}
log_header "Tests for RELEASE_TYPE"
assertReleaseType "5.2.0-SNAPSHOT" "snapshot"
assertReleaseType "5.2-SNAPSHOT" "snapshot"
assertReleaseType "5.2.0-BETA-1" "beta"
assertReleaseType "5.2-BETA-1" "beta"
assertReleaseType "5.0" "stable"
assertReleaseType "5.1" "stable"
assertReleaseType "5.1.1" "stable"
assertReleaseType "5.2.0" "stable"
function assertPackageVersions {
export HZ_VERSION=$1
export PACKAGE_VERSION=$2
local expectedDebVersion=$3
local expectedRpmVersion=$4
. "$SCRIPT_DIR"/common.sh
local msg="DEB_PACKAGE_VERSION for (HZ_VERSION=$HZ_VERSION, PACKAGE_VERSION=$PACKAGE_VERSION) should be $expectedDebVersion"
assert_eq "$expectedDebVersion" "$DEB_PACKAGE_VERSION" "$msg" && log_success "$msg" || TESTS_RESULT=$?
msg="RPM_PACKAGE_VERSION for (HZ_VERSION=$HZ_VERSION, PACKAGE_VERSION=$PACKAGE_VERSION) should be $expectedRpmVersion"
assert_eq "$expectedRpmVersion" "$RPM_PACKAGE_VERSION" "$msg" && log_success "$msg" || TESTS_RESULT=$?
}
log_header "Tests for DEB_PACKAGE_VERSION and RPM_PACKAGE_VERSION"
assertPackageVersions "5.0.2" "5.0.2" "5.0.2-1" "5.0.2-1"
assertPackageVersions "5.0.2" "5.0.2-1" "5.0.2-1" "5.0.2-1"
assertPackageVersions "5.1" "5.1" "5.1-1" "5.1-1"
assertPackageVersions "5.1" "5.1-1" "5.1-1" "5.1-1"
assertPackageVersions "5.1-SNAPSHOT" "5.1-SNAPSHOT" "5.1-SNAPSHOT-1" "5.1.SNAPSHOT-1"
assertPackageVersions "5.1-BETA-1" "5.1-BETA-1" "5.1-BETA-1-1" "5.1.BETA.1-1"
assertPackageVersions "5.1-BETA-1" "5.1-BETA-1-2" "5.1-BETA-1-2" "5.1.BETA.1-2"
assertPackageVersions "5.2.0-SNAPSHOT" "5.2.0-SNAPSHOT" "5.2.0-SNAPSHOT-1" "5.2.0.SNAPSHOT-1"
function assertMinorVersion {
export HZ_VERSION=$1
local expected=$2
. "$SCRIPT_DIR"/common.sh
local msg="Version $HZ_VERSION should be mapped to $expected minor version"
assert_eq "$expected" "$HZ_MINOR_VERSION" "$msg" && log_success "$msg" || TESTS_RESULT=$?
}
log_header "Tests for HZ_MINOR_VERSION"
assertMinorVersion "5.2-SNAPSHOT" "5.2-SNAPSHOT"
assertMinorVersion "5.2.0-SNAPSHOT" "5.2.0-SNAPSHOT"
assertMinorVersion "5.2.0-BETA-1" "5.2.0-BETA-1"
assertMinorVersion "5.10" "5.10"
assertMinorVersion "5.10.1" "5.10"
assertMinorVersion "5.0" "5.0"
assertMinorVersion "5.1.1" "5.1"
assertMinorVersion "5.2.0" "5.2"
assert_eq 0 "$TESTS_RESULT" "All tests should pass"