diff --git a/lib/detik.bash b/lib/detik.bash index db6667e..d84c113 100644 --- a/lib/detik.bash +++ b/lib/detik.bash @@ -145,7 +145,7 @@ verify() { echo "An empty expression was not expected." return 1 - elif [[ "$exp" =~ $verify_regex_count_is ]] || [[ "$exp" =~ $verify_regex_count_are ]] || [[ "$exp" =~ $verify_regex_count_less_than ]] || [[ "$exp" =~ $verify_regex_count_more_than ]]; then + elif [[ "$exp" =~ $verify_regex_count_is ]] || [[ "$exp" =~ $verify_regex_count_are ]] || [[ "$exp" =~ $verify_regex_count_is_less_than ]] || [[ "$exp" =~ $verify_regex_count_is_more_than ]]; then card="${BASH_REMATCH[1]}" resource=$(to_lower_case "${BASH_REMATCH[2]}") name="${BASH_REMATCH[3]}" @@ -168,15 +168,14 @@ verify() { detik_debug "-----DETIK:end-----" detik_debug "" - if [[ "$exp" =~ "less" ]]; then + if [[ "$exp" =~ "less than" ]]; then if [[ "$result" -lt "$card" ]]; then echo "Found $result $resource named $name (less than $card as expected)." else echo "Found $result $resource named $name (instead of less than $card expected)." - return 3 - + return 3 fi - elif [[ "$exp" =~ "more" ]]; then + elif [[ "$exp" =~ "more than" ]]; then if [[ "$result" -gt "$card" ]]; then echo "Found $result $resource named $name (more than $card as expected)." else @@ -284,7 +283,7 @@ verify_value() { element=$(cut -d ' ' -f 1 <<< "$line" | xargs) # Compare with an exact value (case insensitive) - if [[ "$exp" =~ "more" ]]; then + if [[ "$exp" =~ "more than" ]]; then if [[ "$value" -gt "$expected_value" ]]; then echo "$element matches the regular expression (found $value)." valid=$((valid + 1)) @@ -292,7 +291,7 @@ verify_value() { echo "Current value for $element is not more than $expected_value..." invalid=$((invalid + 1)) fi - elif [[ "$exp" =~ "less" ]]; then + elif [[ "$exp" =~ "less than" ]]; then if [[ "$value" -lt "$expected_value" ]]; then echo "$element matches the regular expression (found $value)." valid=$((valid + 1)) diff --git a/lib/utils.bash b/lib/utils.bash index cfcd6b8..0ab6252 100644 --- a/lib/utils.bash +++ b/lib/utils.bash @@ -12,8 +12,8 @@ try_regex_find_matching="^at +most +([0-9]+) +times +every +([0-9]+)s +to +find # The regex for the "verify" key word verify_regex_count_is="^there +is +(0|1) +([a-z]+) +named +'([^']+)'$" verify_regex_count_are="^there +are +([0-9]+) +([a-z]+) +named +'([^']+)'$" -verify_regex_count_less_than="^there are less than +([0-9]+) +([a-z]+) +named +'([^']+)'$" -verify_regex_count_more_than="^there are more than +([0-9]+) +([a-z]+) +named +'([^']+)'$" +verify_regex_count_is_less_than="^there are less than +([0-9]+) +([a-z]+) +named +'([^']+)'$" +verify_regex_count_is_more_than="^there are more than +([0-9]+) +([a-z]+) +named +'([^']+)'$" verify_regex_property_is="^'([^']+)' +is +'([^']+)' +for +([a-z]+) +named +'([^']+)'$" verify_regex_property_matches="^'([^']+)' +matches +'([^']+)' +for +([a-z]+) +named +'([^']+)'$" diff --git a/tests/test.detik.try.to.verify.is.bats b/tests/test.detik.try.to.verify.is.bats index b0e5332..42f38d9 100755 --- a/tests/test.detik.try.to.verify.is.bats +++ b/tests/test.detik.try.to.verify.is.bats @@ -265,4 +265,4 @@ mytest_deployment(){ [ ${#lines[@]} -eq 2 ] [ "${lines[0]}" = "Valid expression. Verification in progress..." ] [ "${lines[1]}" = "Current value for nginx is not less than 1..." ] -} \ No newline at end of file +}