-
Notifications
You must be signed in to change notification settings - Fork 503
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
Support default values when capturing variables or enable a way to dynamically generate boolean variables #3436
Comments
Another option instead of allowing defaults in variable capturing is to allow predicates (e.g. For example, storing the result of a predicate into a variable would allow me to set a variable to Or, if none of the above options are wanted, the |
Hi guys, We had a very clear model with queries, captures and asserts:
Now, I think we're going to a model where there are expressions everywhere. You can correct me @fabricereix if I'm mistaken but the model will be:
We want to express "naturally" this kind of file:
Or
It seems natural so we want to support it. Default values can fit into the expression model, for instance (syntax TBD):
We're going to make small steps towards this model, starting with the next version where we're introducing functions. We want to have a clean model and the code that's reflecting that so everything is maintainable and can be augmented. @fabricereix maybe we can write all this in a spec doc, it's helped a lot for previous features and everybody can improve it if we miss some things/usecases. |
@jcamiel Love this end game! If we can get this flexibility, Hurl will be top-notch and will be able to model most of the common user journey flows. Let me know if there is any way I can help, even if just for testing 😅 |
Yes!! it will be nice to rely only on expressions for everything. This more generic model will unlock many use cases. Another uniformization, we might consider, is choosing only one syntax between the current query syntax or the placeholder one.
and
If both of them have an expression after the ':', we might want to have exactly the same syntax. |
Problem to solve
I am writing a test suite for an API, and I want to use the
skip
option to conditionally run some requests based on the response of a previous request.The condition depends on the previous response containing a certain field with a specific value, e.g.
$.result.id
, or the response containing (or not) certain items.However, if I use the following, it fails when the ID doesn't exist (e.g. indicates a failure of resource creation):
Example error:
I cannot even proceed to the next step, which will conditionally create the resource if it doesn't exist. In other test suites, I might want to delete it if it already exists to get back to a clean state.
I tried using the filter syntax with recursive descent, which gives me back an empty array (e.g.
db_id: jsonpath "$.result[?(@.uuid)]..uuid"
). But this doesn't work either, since the empty array is not a valid type to be put into theskip
option.Proposal
Allow captures to provide a default value to variables if the specified filter results in a missing value. Or provide an option that will make the captures without valid value resolutions to not fail the script and just leave the variable with its previous value (so that I can preset it to a default).
In the end, what I need is a way to declare a variable with a boolean value that can be passed to
skip
, based on the response of a previous request.Additional context and resources
Tasks to complete
The text was updated successfully, but these errors were encountered: