Colorize string test helper results

This commit is contained in:
Katrina Verey 2022-03-23 19:19:28 -04:00
parent 221b60fb82
commit af059a0731
No known key found for this signature in database
GPG Key ID: 836031A2C9F15C08

View File

@ -328,12 +328,16 @@ kube::test::if_has_string() {
local match=$2 local match=$2
if grep -q "${match}" <<< "${message}"; then if grep -q "${match}" <<< "${message}"; then
echo -n "${green}"
echo "Successful" echo "Successful"
echo -n "${reset}"
echo "message:${message}" echo "message:${message}"
echo "has:${match}" echo "has:${match}"
return 0 return 0
else else
echo -n "${bold}${red}"
echo "FAIL!" echo "FAIL!"
echo -n "${reset}"
echo "message:${message}" echo "message:${message}"
echo "has not:${match}" echo "has not:${match}"
caller caller
@ -346,13 +350,17 @@ kube::test::if_has_not_string() {
local match=$2 local match=$2
if grep -q "${match}" <<< "${message}"; then if grep -q "${match}" <<< "${message}"; then
echo -n "${bold}${red}"
echo "FAIL!" echo "FAIL!"
echo -n "${reset}"
echo "message:${message}" echo "message:${message}"
echo "has:${match}" echo "has:${match}"
caller caller
return 1 return 1
else else
echo -n "${green}"
echo "Successful" echo "Successful"
echo -n "${reset}"
echo "message:${message}" echo "message:${message}"
echo "has not:${match}" echo "has not:${match}"
return 0 return 0
@ -362,11 +370,16 @@ kube::test::if_has_not_string() {
kube::test::if_empty_string() { kube::test::if_empty_string() {
local match=$1 local match=$1
if [ -n "${match}" ]; then if [ -n "${match}" ]; then
echo -n "${bold}${red}"
echo "FAIL!"
echo "${match} is not empty" echo "${match} is not empty"
echo -n "${reset}"
caller caller
return 1 return 1
else else
echo -n "${green}"
echo "Successful" echo "Successful"
echo -n "${reset}"
return 0 return 0
fi fi
} }