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

Is there a better way to write this scenario in terms of clarity? #636

Closed
j4t1nd3r opened this issue Jul 6, 2022 · 1 comment
Closed

Comments

@j4t1nd3r
Copy link

j4t1nd3r commented Jul 6, 2022

I have the following reg ex which matches on multiple naming conventions:

    [a-z]{2}aip(dev|test|uat|prod)[a-z]{3}
    [a-z]{2,4}-aip-(dev|test|uat|prod)           
    [a-z]{2,4}-aip-([a-z]{2})-(dev|test|uat|prod)

I want to make sure every resource in the plan file adheres to one of these 3 naming conventions. I may add more conventions in the future. I got the following scenario that works:

Scenario: Ensure that resource names follow naming conventions
        Gives I have resources defined
        When it has name
        Then it must have name
        Then its value must match the "([a-z]{2}aip(dev|test|uat|prod)[a-z]{3})|([a-z]{2,4}-aip-(dev|test|uat|prod))|([a-z]{2,4}-aip-([a-z]{2})-(dev|test|uat|prod))" regex

However its not very readable. Is there a better way of writing this that potentially would involve an example table? It needs to match one of them. If a resource does not match any of these then the test should throw a fail.

@j4t1nd3r
Copy link
Author

no longer relevant, closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant