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

Default variable values #27

Open
kyleect opened this issue Dec 2, 2024 · 0 comments
Open

Default variable values #27

kyleect opened this issue Dec 2, 2024 · 0 comments
Labels
enhancement New feature or request scope:parsing Parsing request files, resolve, and template values scope:validation Validating request and request template files
Milestone

Comments

@kyleect
Copy link
Member

kyleect commented Dec 2, 2024

  • Default to using default env if one isn't passed during templating
  • Default to using default when resolving variable values on a parsed request file
  • Allow envs to skill defining a value for a variable if a value was defined in the default environment
```%config
vars = ["greeting", "name"]

[envs.default]
greeting = "Hello"

[envs.dev]
greeting = "Greetings"
name = "Tester"

[envs.prod]
# greeting = "Hello"
name = "World"
```

```%request
POST https://httpbin.org/post HTTP/1.1
content-type: application/x-www-form-urlencoded

say={{:greeting}}&to={{:name}}
```

```%response
HTTP/1.1 200 OK
```

Scenarios

Single Variable

Default environment returns default env value

Given variables ["value"]
And envs.default.value = 123
And envs.test.value = 456
When env is "default"
Then the variable value is 123

Defined environment returns defined env value

Given variables ["value"]
And envs.default.value = 123
And envs.test.value = 456
When env is "test"
Then the variable value is 456

Multi Variable

Given variables ["valueA", "valueB"]
And envs.default.valueA = 123
And envs.test.valueA = 456
And envs.test.valueB = 999
When env is "default"
Then there is a validation error that valueB isn't resolved

Given variables ["valueA", "valueB"]
And envs.default.valueA = 123
And envs.test.valueA = 456
And envs.test.valueB = 999
When env is "test"
Then the variable valueA is 456
And the variable valueB is 999

@kyleect kyleect added scope:parsing Parsing request files, resolve, and template values scope:validation Validating request and request template files enhancement New feature or request labels Dec 2, 2024
@kyleect kyleect changed the title Don't allow "default" env if other envs declared Default variable values Jan 24, 2025
@kyleect kyleect removed the scope:validation Validating request and request template files label Jan 24, 2025
@kyleect kyleect added this to the MVP milestone Jan 29, 2025
@kyleect kyleect added the scope:validation Validating request and request template files label Jan 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request scope:parsing Parsing request files, resolve, and template values scope:validation Validating request and request template files
Projects
None yet
Development

No branches or pull requests

1 participant