You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is there a way to check if a specific tag key (e.g. department) has one of a list of possible values (e.g. IT, Marketing, HR)? Kind of like a scenario outline
Is there a way to enforce a regex pattern on values assigned to a tag? Name definitely come to mind here?
Can we check that a tag is not empty?
You kindly provided the following example:
Scenario: Ensure that specific tags are defined
Given I have resource that supports tags defined
When it contains tags
Then its value must match the "(IT|Marketing|HR)" regex
If I extend the example a bit to the following I able able to deal with all my use cases above:
Scenario: Ensure that Role tag is defined
Given I have resource that supports tags defined
When it contains tags
Then it must contain role
And its value must match the "^[a-z]+role" regex
Scenario: Ensure that BusinessUnit tag is defined
Given I have resource that supports tags defined
When it contains tags
Then it must contain BusinessUnit
And its value must match the "^(IT|Marketing|HR)$" regex
The problem with this approach is that I would have to write basically the same scenario for each tag and regex. Not terrible but it would be better with a Scenario Outline.
I tried the following and it worked:
Scenario Outline: Ensure that my specific tags are defined
Given I have resource that supports tags defined
When it contains tags
Then it must contain <tag_keys>
And its value must match the "<pattern>" regex
Examples:
| tag_keys | pattern |
| role | ^[a-z]+role |
The following did not work however:
Scenario Outline: Ensure that my specific tags are defined
Given I have resource that supports tags defined
When it contains tags
Then it must contain <tag_keys>
And its value must match the "<pattern>" regex
Examples:
| tag_keys | pattern |
| BusinessUnit | ^(IT|Marketing|HR)$ |
It fails with the following error:
Error: Hook 'console_writer_after_each_scenario' from /usr/local/lib/python3.7/site-packages/radish/extensions/formatters/gherkin.py:425 raised: 'RadishError: Invalid colum_index to get column width for ScenarioOutline 'Ensure that my specific tags are defined''
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/radish/scenariooutline.py", line 125, in get_column_width
max([len(x.data[column_index]) for x in self.examples]),
File "/usr/local/lib/python3.7/site-packages/radish/scenariooutline.py", line 125, in <listcomp>
max([len(x.data[column_index]) for x in self.examples]),
IndexError: list index out of range
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/radish/hookregistry.py", line 132, in call
func(model, *args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/radish/extensions/formatters/gherkin.py", line 467, in console_writer_after_each_scenario
for i, x in enumerate(scenario.example.data)
File "/usr/local/lib/python3.7/site-packages/radish/extensions/formatters/gherkin.py", line 467, in <genexpr>
for i, x in enumerate(scenario.example.data)
File "/usr/local/lib/python3.7/site-packages/radish/scenariooutline.py", line 131, in get_column_width
self.sentence
radish.exceptions.RadishError: Invalid colum_index to get column width for ScenarioOutline 'Ensure that my specific tags are defined'
I believe it has to do with the pipe character but I am not sure.
Any chance support for this can get added?
The text was updated successfully, but these errors were encountered:
Thanks for the finding! This time it is not about terraform-compliance but it is about Gherkin/Cucumber support on radish-bdd. Ideally we should be able to escape | character within Scenario Outlines by \|, but it look like it is also failing.
Using | within the Scenarios (by escaping them like \| is introduced on radish-bdd/radish#351 and also incorporated on terraform-compliance1.0.13. Could you please have a try ?
This is a follow up to #96
There I asked if the following were possible:
Is there a way to check if a specific tag key (e.g. department) has one of a list of possible values (e.g. IT, Marketing, HR)? Kind of like a scenario outline
Is there a way to enforce a regex pattern on values assigned to a tag? Name definitely come to mind here?
Can we check that a tag is not empty?
You kindly provided the following example:
If I extend the example a bit to the following I able able to deal with all my use cases above:
The problem with this approach is that I would have to write basically the same scenario for each tag and regex. Not terrible but it would be better with a Scenario Outline.
I tried the following and it worked:
The following did not work however:
It fails with the following error:
I believe it has to do with the pipe character but I am not sure.
Any chance support for this can get added?
The text was updated successfully, but these errors were encountered: