Skip to content

Commit cbf662c

Browse files
committed
add test.sh
1 parent cdacecc commit cbf662c

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed

test.sh

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#!/bin/bash
2+
run_test() {
3+
local name=$1
4+
local node=$2
5+
local script=$3
6+
echo "==== test: $1 (node: $2) ===="
7+
8+
local expected="$(mktemp)"
9+
local got="$(mktemp)"
10+
11+
if diff --strip-trailing-cr -u <(sh -c "$script") <(set -x; ./kubectl-node_shell $node -- sh -c "$script"); then
12+
echo -e "Result: \e[42mPASS\e[49m"
13+
else
14+
echo -e "Result: \e[101mFAIL\e[49m"
15+
fi
16+
17+
rm -f "$expected" "$got"
18+
}
19+
20+
if [ -z $1 ]; then
21+
echo "please specify node in first argument" >&2
22+
exit -1
23+
fi
24+
25+
case1=$(cat <<\EOT
26+
echo $(echo "
27+
hello everybody
28+
I'm a \"baby seal\""
29+
30+
)
31+
EOT
32+
)
33+
34+
case2=$(cat <<\EOT
35+
36+
echo "ggg
37+
38+
39+
ttt"
40+
EOT
41+
)
42+
43+
case3=$(cat <<\EOT
44+
echo $(echo "
45+
hello everybody
46+
I'm a \"baby seal
47+
48+
really really
49+
50+
\""
51+
)
52+
EOT
53+
)
54+
55+
run_test "case 1" "$1" "$case1"
56+
run_test "case 2" "$1" "$case2"
57+
run_test "case 3" "$1" "$case3"

0 commit comments

Comments
 (0)