-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
Fix using dashes in AWS resource tags, add unit tests #8766
Conversation
Codecov Report
@@ Coverage Diff @@
## master #8766 +/- ##
==========================================
+ Coverage 87.60% 87.77% +0.17%
==========================================
Files 260 265 +5
Lines 9664 9913 +249
==========================================
+ Hits 8466 8701 +235
- Misses 1198 1212 +14
Continue to review full report at Codecov.
|
9119126
to
0227571
Compare
Added tests for the 128 character maximum length too |
@pgrzesik escaping the dash did the trick indeed. The dot needed escaping too (I'm actually not 100% sure about that, but it might be safest to escape it anyway to avoid confusion). |
I found #8051, but I can't dig up the tests that were inevitably scrapped from the pull request. Maybe reconsider not testing these validations at all? Clearly they are the source of multiple bugs, and complicating testing makes the barrier to entry for fixing them higher. I mean, I've already fixed the bug and written tests. I agree that simple validations don't need testing because the logic is part of |
We don't want to fall into practice of writing tests for regular expressions confirming that they support all intended notations. Approach we have is that we test properties of which format is validated through regular expression. Here the real problem is not that regex was invalid, but that we didn't support given notation for a property, and that should simply addressed by (1) improving the regex which backs validation of that property, and (2) ensuring a regression test, that confirms, that given notation is now supported for given property. So when testing is concerned I would simply add previously not supported notation e.g. in this test: serverless/test/unit/lib/plugins/aws/package/compile/functions.test.js Lines 379 to 414 in 420e937
|
0227571
to
1a3c2e9
Compare
@medikoo I changed the way the test is done, please review again |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @Jalle19 ! It's way better, I've just proposed a different approach to testing, which we practice in context of this project.
1a3c2e9
to
3a39e5a
Compare
@medikoo I removed the tests and added just a few more defined tags to the existing test case. I'm not a fan of this solution since it can only test that valid values are allowed, not that invalid values are disallowed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @Jalle19 ! It looks great now, I've just proposed to reduce noise in regex and clear obsolete escape
3a39e5a
to
4e25b2b
Compare
This should be good to go now IMO, can't make the change any smaller |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @Jalle19, looks great!
This regular expression has been broken before, it's time it gets tested properly
Closes: #8764
I'm not sure whether
naming.js
is the best location to move the regular expression to, but it was the best I could find given that I'm not familiar with the codebase.