Open tnicolaisen-snabble opened 1 year ago
Hi, thanks for the detailed report.
Variables are typed, but we haven't well documented what are the conversion rules. For instance ,
$ hurl --very-verbose --variable enable="true" /tmp/test.hurl
The variable enable
will be considered by Hurl as a boolean value. If you really want to use true
as a string, you can write:
hurl --very-verbose --variable enable='"true"' /tmp/test.hurl
For your case, you can use:
hurl --very-verbose --variable dayOfYear='"003"' /tmp/test.hurl
And dayOfYear
will be considered as the string 003
.
We definitively should document it, and see if we need an exception for input like 000123456
.
@jcamiel Got it! Thanks for the swift response, on a Sunday no less :)
For reference, it took a bit more fiddling to pass the parameter in through a shell script. This worked:
dayOfYear=\"$(date '+%j')\"
hurl --variable dayOfYear="${dayOfYear}" sandbox.hurl
Thanks, we're still going to add an exception for the int case, i.e considering
See @fabricereix comment0000123456789
as a string!
A few examples in the bash
a=001 integer <1> # the leading zeros are removed by Hurl
a="001" integer <1> # the quote are removed by the shell
a=\"001\" string <001> # the quotes are passed to Hurl that can treat the value as a String
a=" 001" string < 001> # Hurl treats the value as String because it contains a space
a=\"\"001\"\" string <"001"> # one pair of quotes is used to type the value as string, one is part of the value
idem for boolean
a=true boolean <true>
a="true" boolean <true> # the quote are removed by the shell
a=\"true\" string <true> # the quotes are passed to Hurl that can treat the value as a String
a=" true" string < true> # Hurl treats the value as String because it contains a space
a=\"\"true\"\" string <"true"> # one pair of quotes is used to type the value as string, one is part of the value
We will still parse 0000123456789
as an integer (like Rust).
We will add theses examples to the documentation.
Summary
We're calling a service that requires day-of-year as a 3 digit number, "001" being Jan 1st, and so on.
When running a hurl script with a variable that contains leading zeros, they get trimmed.
Steps to reproduce
Hurl file:
What is the current bug behavior?
The output is:
What is the expected correct behavior?
I expected the resulting "dayOfYear" to have the value "003".
Output of checks
hurl --version:
Thanks for having a look!