-
Notifications
You must be signed in to change notification settings - Fork 3
/
backport.functions_tests
executable file
·56 lines (45 loc) · 2.16 KB
/
backport.functions_tests
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
#!/usr/bin/env bash
set -eu
SCRIPT_DIR=$(readlink -f "$0")
SCRIPT_DIR="$(dirname "${SCRIPT_DIR}")"
# Source the latest version of assert.sh unit testing library and include in current shell
curl --silent https://raw.githubusercontent.com/hazelcast/assert.sh/main/assert.sh --output assert.sh
# shellcheck source=/dev/null
# You _should_ be able to avoid a temporary file with something like
# . <(echo "${assert_script_content}")
# But this doesn't work on the MacOS GitHub runner (but does on MacOS locally)
. assert.sh
# shellcheck source=/dev/null
. "${SCRIPT_DIR}"/backport.functions
TESTS_RESULT=0
function test_get_pr_number {
local commit_msg=$1
local expected_pr_number=$2
local actual_pr_number=$(get_pr_number "$commit_msg")
local MSG="Expected PR Number extracted from \"$commit_msg\" should be equal to \"$expected_pr_number\""
assert_eq "$expected_pr_number" "$actual_pr_number" "$MSG" && log_success "$MSG" || TESTS_RESULT=$?
}
function test_get_pr_reviewers {
local repo_upstream=$1
local pr_number=$2
local expected_reviewers=$3
local actual_reviewers=$(get_pr_reviewers "$repo_upstream" "$pr_number")
local MSG="Expected reviewers extracted from \"$repo_upstream/pull/$pr_number\" should be equal to \"$expected_reviewers\""
assert_eq "$expected_reviewers" "$actual_reviewers" "$MSG" && log_success "$MSG" || TESTS_RESULT=$?
}
function test_get_pr_labels {
local repo_upstream=$1
local pr_number=$2
local expected_labels=$3
local actual_labels=$(get_pr_labels "$repo_upstream" "$pr_number")
local MSG="Expected labels extracted from \"$repo_upstream/pull/$pr_number\" should be equal to \"$actual_labels\""
assert_eq "$expected_labels" "$actual_labels" "$MSG" && log_success "$MSG" || TESTS_RESULT=$?
}
log_header "Tests for get_pr_number"
test_get_pr_number 'Fix private test repository access [DI-236] (#221)' '221'
test_get_pr_number 'Fix private test repository access [DI-236] (#221) (#222)' '222'
log_header "Tests for get_pr_reviewers"
test_get_pr_reviewers 'hazelcast/backport' '1' 'ldziedziul'
log_header "Tests for get_pr_labels"
test_get_pr_labels 'hazelcast/backport' '1' 'enhancement'
assert_eq 0 "$TESTS_RESULT" "All tests should pass"