@@ -40,7 +40,7 @@ try() {
40
40
expected_count=" "
41
41
verify_strict_equality=" true"
42
42
43
- if [[ " $exp " =~ $try_regex_verify_is ]]; then
43
+ if [[ " $exp " =~ $try_regex_verify_is ]] || [[ " $exp " =~ $try_regex_verify_is_more_than ]] || [[ " $exp " =~ $try_regex_verify_is_less_than ]] ; then
44
44
45
45
# Extract parameters
46
46
times=" ${BASH_REMATCH[1]} "
@@ -97,7 +97,7 @@ try() {
97
97
for (( i= 1 ; i<= times; i++ )) ; do
98
98
99
99
# Verify the value
100
- verify_value " $verify_strict_equality " " $property " " $expected_value " " $resource " " $name " " $expected_count " && code=$? || code=$?
100
+ verify_value " $verify_strict_equality " " $property " " $expected_value " " $resource " " $name " " $expected_count " " $exp " && code=$? || code=$?
101
101
102
102
# Break the loop prematurely?
103
103
if [[ " $code " == " 0" ]]; then
@@ -145,7 +145,7 @@ verify() {
145
145
echo " An empty expression was not expected."
146
146
return 1
147
147
148
- elif [[ " $exp " =~ $verify_regex_count_is ]] || [[ " $exp " =~ $verify_regex_count_are ]]; then
148
+ 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
149
149
card=" ${BASH_REMATCH[1]} "
150
150
resource=$( to_lower_case " ${BASH_REMATCH[2]} " )
151
151
name=" ${BASH_REMATCH[3]} "
@@ -168,7 +168,21 @@ verify() {
168
168
detik_debug " -----DETIK:end-----"
169
169
detik_debug " "
170
170
171
- if [[ " $result " == " $card " ]]; then
171
+ if [[ " $exp " =~ " less than" ]]; then
172
+ if [[ " $result " -lt " $card " ]]; then
173
+ echo " Found $result $resource named $name (less than $card as expected)."
174
+ else
175
+ echo " Found $result $resource named $name (instead of less than $card expected)."
176
+ return 3
177
+ fi
178
+ elif [[ " $exp " =~ " more than" ]]; then
179
+ if [[ " $result " -gt " $card " ]]; then
180
+ echo " Found $result $resource named $name (more than $card as expected)."
181
+ else
182
+ echo " Found $result $resource named $name (instead of more than $card expected)."
183
+ return 3
184
+ fi
185
+ elif [[ " $result " == " $card " ]]; then
172
186
echo " Found $result $resource named $name (as expected)."
173
187
else
174
188
echo " Found $result $resource named $name (instead of $card expected)."
@@ -227,6 +241,7 @@ verify_value() {
227
241
resource=" $4 "
228
242
name=" $5 "
229
243
expected_count=" $6 "
244
+ exp=" $7 "
230
245
231
246
# List the items and remove the first line (the one that contains the column names)
232
247
query=$( build_k8s_request " $property " )
@@ -268,7 +283,23 @@ verify_value() {
268
283
element=$( cut -d ' ' -f 1 <<< " $line" | xargs)
269
284
270
285
# Compare with an exact value (case insensitive)
271
- if [[ " $verify_strict_equality " == " true" ]]; then
286
+ if [[ " $exp " =~ " more than" ]]; then
287
+ if [[ " $value " -gt " $expected_value " ]]; then
288
+ echo " $element matches the regular expression (found $value )."
289
+ valid=$(( valid + 1 ))
290
+ else
291
+ echo " Current value for $element is not more than $expected_value ..."
292
+ invalid=$(( invalid + 1 ))
293
+ fi
294
+ elif [[ " $exp " =~ " less than" ]]; then
295
+ if [[ " $value " -lt " $expected_value " ]]; then
296
+ echo " $element matches the regular expression (found $value )."
297
+ valid=$(( valid + 1 ))
298
+ else
299
+ echo " Current value for $element is not less than $expected_value ..."
300
+ invalid=$(( invalid + 1 ))
301
+ fi
302
+ elif [[ " $verify_strict_equality " == " true" ]]; then
272
303
value=$( to_lower_case " $value " )
273
304
expected_value=$( to_lower_case " $expected_value " )
274
305
if [[ " $value " != " $expected_value " ]]; then
@@ -278,7 +309,6 @@ verify_value() {
278
309
echo " $element has the right value ($value )."
279
310
valid=$(( valid + 1 ))
280
311
fi
281
-
282
312
# Verify a regex (we preserve the case)
283
313
else
284
314
# We do not want another syntax for case-insensitivity
0 commit comments