Skip to content

Instantly share code, notes, and snippets.

@smarterclayton
Created September 26, 2016 18:11
Show Gist options
  • Save smarterclayton/6bc2c47d87c188470083465726bb42f4 to your computer and use it in GitHub Desktop.
Save smarterclayton/6bc2c47d87c188470083465726bb42f4 to your computer and use it in GitHub Desktop.
*** before stupid
+ kube::test::if_has_string 'Error from server: pods "abc" not found' List
+ local 'message=Error from server: pods "abc" not found'
+ local match=List
++ echo 'Error from server: pods "abc" not found'
++ grep List
+ [[ -n '' ]]
+ echo 'FAIL!'
FAIL!
+ echo 'message:Error from server: pods "abc" not found'
message:Error from server: pods "abc" not found
+ echo 'has not:List'
has not:List
+ caller
1035 hack/make-rules/test-cmd.sh
+ return 1
+ echo '*** after stupid'
*** after stupid
+ create_and_use_new_namespace
echo "*** before stupid"
set -x
if kube::test::if_has_string "${output_message}" 'List'; then
echo "*** in stupid"
    echo 'Unexpected List output'
    echo '---'
    echo "${output_message}"
    echo '---'
    echo "${LINENO} $(basename $0)"
    exit 1
  fi
echo "*** after stupid"
kube::test::if_has_string() {
  local message=$1
  local match=$2

  if [[ $(echo "$message" | grep "$match") ]]; then
    echo "Successful"
    echo "message:$message"
    echo "has:$match"
    return 0
  else
    echo "FAIL!"
    echo "message:$message"
    echo "has not:$match"
    caller
    return 1
  fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment