Variables as values
Closed this issue · 0 comments
Currently variables are defined as strings only.
There's no reason they couldn't be defined as values instead (provided the user doesn't try to expand them in the middle of a string). This could enable entire requests to be captured as variables, eliminating more repeat work.
suite: Recipe Test
variables:
RECIPE_REQUEST:
method: GET
url: http://localhost:3000/recipes
tests:
- test: Gets a recipe
request: ${RECIPE_REQUEST}
expect:
status: 2xx
Initially, the deserialization would interpret the request as a Value::String("${RECIPE_REQUEST}"), and variable population could take in this Value and return a Value, and in this case take in a Value::String and return a Value::Object.
There would have to be handling of cases where more of a string is defined - what should happen, for example, if in this case the user tries to define `some_field: "Request info: ${RECIPE_REQUEST}" - ideally the app should never exit early, so this will need to be handled - perhaps by serializing the request object as JSON and inserting it into the string.