-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_bunity
More file actions
executable file
·56 lines (47 loc) · 1.51 KB
/
test_bunity
File metadata and controls
executable file
·56 lines (47 loc) · 1.51 KB
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
. ./bunity
function evaluate {
local the_test="${1}"
local the_message="${2}"
test "${the_test}"
if [[ ${?} == 0 ]]; then
echo -n '.'
else
echo -e "F\n${the_message}"
exit 1
fi
}
function test_setup {
local the_path="${PATH}"
local expected="${PATH}:."
setup
local obtained="${PATH}"
export PATH="${the_path}"
evaluate "'${expected}' == '${obtained}'" "F\n${FUNCNAME}: it can't add this folder to its PATH section."
}
function test_teardown {
local path_salvo="${PATH}"
the_path="${path_salvo}"
local expected="${the_path}"
export PATH="blablabla"
teardown >/dev/null
local obtained="${PATH}"
export PATH="${path_salvo}"
evaluate "'${expected}' == '${obtained}'" "F\n${FUNCNAME}: expected PATH equals to [${expected}], but got [${obtained}]."
local expected="$(echo -e '\nOK')"
local obtained=$(teardown)
export PATH="${path_salvo}"
evaluate "'${expected}' == '${obtained}'" "F\n${FUNCNAME}: expected return message as [${expected}], but got [${obtained}]."
}
function test_assert_equals {
local expected="$(echo -e "F\ntest_assert_equals: expected [1], but got [2].")"
local obtained="$(assert_equals '1' '2' 2>&1)"
evaluate "'${expected}' == '${obtained}'" "F\n${FUNCNAME}: expected return message as [${expected}], but got [${obtained}]."
local expected="."
local obtained="$(assert_equals '1' '1' 2>&1)"
evaluate "'${expected}' == '${obtained}'" "F\n${FUNCNAME}: expected return message as [${expected}], but got [${obtained}]."
}
test_setup
test_teardown
test_assert_equals
echo -e '\nOK'
exit 0