From 9dbfa1fb75b74876248b1c89439db45a836e8b18 Mon Sep 17 00:00:00 2001 From: Andrei Kvapil Date: Tue, 13 Jul 2021 11:23:36 +0200 Subject: [PATCH] add test.sh --- test.sh | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100755 test.sh diff --git a/test.sh b/test.sh new file mode 100755 index 0000000..67fdbcf --- /dev/null +++ b/test.sh @@ -0,0 +1,55 @@ +#!/bin/bash +run_test() { + local name=$1 + local node=$2 + local script=$3 + echo "==== test: $1 (node: $2) ====" + + local expected="$(mktemp)" + local got="$(mktemp)" + + if diff --strip-trailing-cr -u <(sh -c "$script") <(set -x; ./kubectl-node_shell $node -- sh -c "$script"); then + echo -e "Result: \e[42mPASS\e[49m" + else + echo -e "Result: \e[101mFAIL\e[49m" + fi +} + +if [ -z $1 ]; then + echo "please specify node in first argument" >&2 + exit -1 +fi + +case1=$(cat <<\EOT +echo $(echo " +hello everybody +I'm a \"baby seal\"" + +) +EOT +) + +case2=$(cat <<\EOT + +echo "ggg + + +ttt" +EOT +) + +case3=$(cat <<\EOT +echo $(echo " +hello everybody +I'm a \"baby seal + +really really + +\"" +) +EOT +) + +run_test "case 1" "$1" "$case1" +run_test "case 2" "$1" "$case2" +run_test "case 3" "$1" "$case3"