forked from JasonGiedymin/container-automation-lib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
core_test.sh
64 lines (53 loc) · 1.11 KB
/
core_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
#!/bin/bash
source ./core.sh
function TestRunCmd() {
local list=("Joe" "Bob" "Dan")
local result=`runCmd "echo" "${list[@]}"`
local expected="Joe
[echo - Joe] exited successfully.
Bob
[echo - Bob] exited successfully.
Dan
[echo - Dan] exited successfully."
echo " ---> [TestRunCmd]"
if [ "$result" != "$expected" ]; then
echo " fail"
echo " TestRunCmd failed with result: $result"
return 0;
else
echo " pass"
return 0;
fi;
}
function TestRunCmdArgs() {
local list=("Joe" "Bob" "Dan")
local result=`runCmd "echo -n" "${list[@]}"`
local expected="Joe[echo -n - Joe] exited successfully.
Bob[echo -n - Bob] exited successfully.
Dan[echo -n - Dan] exited successfully."
if [ "$result" != "$expected" ]; then
echo " fail"
echo " TestRunCmdArgs failed with result: $result"
return 0;
else
echo " pass"
return 0;
fi;
}
init() {
TestRunCmd
local rc=$?
if [ $rc -gt 0 ]; then
echo "Init test failed. This is required to work."
exit 1;
fi;
}
tests() {
local testFuncs=(TestRunCmdArgs)
run "${testFuncs[@]}"
}
main() {
init
tests
}
main