You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It's possible isEmpty only works for arrays/slices, not all collection types, it looks to me like it's just implemented as an alias to count == 0. Probably need to do a type check and have multiple codepaths instead.
The text was updated successfully, but these errors were encountered:
Thanks @taigrr for the issue, it should be fixed on master, you can test it if you know how to build a Rust application (see => Build & Test) or wait for the next Hurl release landing in September. One thing that we can improve (I just need to check with @fabricereix) is do we allow count on an object ?
POST http://server/request
{
"x":"y",
"z":420
}
jsonpath "$.a.b.c" != null # OK
jsonpath "$.a.b.c" isCollection # OK
jsonpath "$.a.b.c" isEmpty # OK
jsonpath "$.a.b.c" count == 0 # ??
Thanks! For my personal use case I am ok with this as-is, and I don't know of a use case for count on an object. I could check individual properties on the object, or I would want to know if it's null or empty or non-empty, but I don't know a real-world use case for count.
What is the current bug behavior?
I have a server returning the following JSON:
{ "a":{ "b":{ "c":{}, "d":{} } } }
And I have a hurl file with the following assertions:
hurl --test *.hurl
According to the documentation:
Since isCollection returns true, my
c
object is a collection. It's clearly empty, why am I getting a type error?What is the expected correct behavior?
I should not get a type error
Execution context
hurl 4.0.0 libcurl/8.2.0 OpenSSL/3.1.1 zlib/1.2.13 brotli/1.0.3840 zstd/1.5.5 libidn2/2.3.4 libssh2/1.11.0 nghttp2/1.55.1
Features (libcurl): alt-svc AsynchDNS brotli HSTS HTTP2 IDN IPv6 Largefile libz NTLM NTLM_WB SPNEGO SSL TLS-SRP UnixSockets zstd
Features (built-in): brotli
archlinux, 6.4.4-arch1-1 #1 SMP PREEMPT_DYNAMIC Wed, 19 Jul 2023 19:19:38 +0000 x86_64 GNU/Linux
Possible fixes
It's possible isEmpty only works for arrays/slices, not all collection types, it looks to me like it's just implemented as an alias to
count == 0
. Probably need to do a type check and have multiple codepaths instead.The text was updated successfully, but these errors were encountered: