Skip to content

Commit 48b29b4

Browse files
#29 Raise an error when no found item and no expected count
1 parent 30e70fc commit 48b29b4

File tree

4 files changed

+8
-5
lines changed

4 files changed

+8
-5
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ without having been verified, an error is thrown. Please, refer to [this section
317317
about the property names.
318318

319319
This assertion verifies all the instances have this property value.
320-
But unlike the assertion type to count resources, you do not verify how many instances have this value.
320+
But unlike the assertion type to count resources, you do not verify how many instances have this value. Notice however that **if it finds 0 item verifying the property, the assertion fails**.
321321

322322

323323
### Property Names

lib/detik.bash

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,9 @@ verify_value() {
244244
else
245245
invalid=0
246246
fi
247+
# If no count expected, raise an error when 0 found items
248+
elif [[ "$valid" == "0" ]]; then
249+
invalid=102
247250
fi
248251

249252
return $invalid

tests/test.detik.try.to.verify.bats

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ mytest() {
110110

111111
@test "trying to verify the status of a POD with an invalid name" {
112112
run try "at most 1 times every 1s to get pods named 'nginx-something' and verify that 'status' is 'running'"
113-
[ "$status" -eq 0 ]
113+
[ "$status" -eq 3 ]
114114
[ ${#lines[@]} -eq 2 ]
115115
[ "${lines[0]}" = "Valid expression. Verification in progress..." ]
116116
[ "${lines[1]}" = "No resource of type 'pods' was found with the name 'nginx-something'." ]
@@ -129,7 +129,7 @@ mytest() {
129129

130130
@test "trying to verify the status of a POD with an invalid pattern name" {
131131
run try "at most 1 times every 1s to get pods named 'ngin.+x' and verify that 'status' is 'running'"
132-
[ "$status" -eq 0 ]
132+
[ "$status" -eq 3 ]
133133
[ ${#lines[@]} -eq 2 ]
134134
[ "${lines[0]}" = "Valid expression. Verification in progress..." ]
135135
[ "${lines[1]}" = "No resource of type 'pods' was found with the name 'ngin.+x'." ]

tests/test.detik.verify.bats

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ mytest_with_namespace() {
324324

325325
@test "verifying the status of a POD with an invalid name" {
326326
run verify "'status' is 'running' for pods named 'nginx-something'"
327-
[ "$status" -eq 0 ]
327+
[ "$status" -eq 3 ]
328328
[ ${#lines[@]} -eq 2 ]
329329
[ "${lines[0]}" = "Valid expression. Verification in progress..." ]
330330
[ "${lines[1]}" = "No resource of type 'pods' was found with the name 'nginx-something'." ]
@@ -343,7 +343,7 @@ mytest_with_namespace() {
343343

344344
@test "verifying the status of a POD with an invalid pattern name" {
345345
run verify "'status' is 'running' for pods named 'ngin.+x'"
346-
[ "$status" -eq 0 ]
346+
[ "$status" -eq 3 ]
347347
[ ${#lines[@]} -eq 2 ]
348348
[ "${lines[0]}" = "Valid expression. Verification in progress..." ]
349349
[ "${lines[1]}" = "No resource of type 'pods' was found with the name 'ngin.+x'." ]

0 commit comments

Comments
 (0)