Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

header type casting missed opportunity #1029

Closed
jlecour opened this issue Nov 26, 2022 · 1 comment · Fixed by #1050
Closed

header type casting missed opportunity #1029

jlecour opened this issue Nov 26, 2022 · 1 comment · Fixed by #1050
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@jlecour
Copy link

jlecour commented Nov 26, 2022

Hi,

Let's say I have an HTTP response with a numeic header : Age: 1337.

I I try to assert a numeric value I get a type error.

header "age" >= 0 gives this error :

error: Assert failure
  --> tests/foo.hurl:30:0
   |
30 | header "age" >= 0
   |   actual:   string <592>
   |   expected: greater or equal than int <0>
   |   >>> types between actual and expected are not consistent
   |

header "age" isInteger gives this error :

error: Assert failure
  --> tests/foo.hurl:30:0
   |
30 | header "age" isInteger
   |   actual:   string <1966>
   |   expected: integer
   |

Is there a filter to force the type casting ?
I feel like I'm missing something here.

I know I cound do this, but it's not great :

header "age" exists
header "age" != "0"

Thanks

@fabricereix
Copy link
Collaborator

Hi @jlecour,
your understanding is right, the value returned by the header query is always a String.
And having a cast filter would indeed feel quite natural. Thanks for your suggestion.
We plan to add a few more filters for the next release, we could include yours.

Something like that

header "age" toInt >= 0

@jcamiel jcamiel added the enhancement New feature or request label Nov 26, 2022
@fabricereix fabricereix linked a pull request Dec 3, 2022 that will close this issue
@jcamiel jcamiel added this to the 2.0.0 milestone Dec 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants