-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Refactor to decouple tests #11812
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
Refactor to decouple tests #11812
Conversation
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## main #11812 +/- ##
==========================================
+ Coverage 86.56% 86.60% +0.04%
==========================================
Files 314 314
Lines 13128 13161 +33
==========================================
+ Hits 11364 11398 +34
+ Misses 1764 1763 -1
... and 1 file with indirect coverage changes Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report in Codecov by Sentry. |
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.
@sleepwithcoffee thanks for taking care of that.
Still to ensure best reliability all tests refactor should be done in a way so new tests run with runServerless util. See https://github.com/serverless/serverless/tree/main/test#unit-tests
And as I checked in more detail we can totally remove the validate.test.js file as:
- Som tests confirm implementation details (we should not write such tests, and we're ok to remove them
- Stage resolution is already well tested here:
serverless/test/unit/lib/plugins/aws/provider.test.js
Lines 760 to 795 in 16dd286
describe('#getStage()', () => { it('should default to "dev"', async () => { const { serverless } = await runServerless({ fixture: 'aws', command: 'print', }); expect(serverless.getProvider('aws').getStage()).to.equal('dev'); }); it('should allow to override via `provider.stage`', async () => { const { serverless } = await runServerless({ fixture: 'aws', command: 'print', configExt: { provider: { stage: 'staging', }, }, }); expect(serverless.getProvider('aws').getStage()).to.equal('staging'); }); it('should allow to override via CLI `--stage` param', async () => { const { serverless } = await runServerless({ fixture: 'aws', command: 'print', options: { stage: 'production' }, configExt: { provider: { stage: 'staging', }, }, }); expect(serverless.getProvider('aws').getStage()).to.equal('production'); }); }); - Region resolution is already tested here:
serverless/test/unit/lib/plugins/aws/provider.test.js
Lines 591 to 626 in 16dd286
describe('#getRegion()', () => { it('should default to "us-east-1"', async () => { const { serverless } = await runServerless({ fixture: 'aws', command: 'print', }); expect(serverless.getProvider('aws').getRegion()).to.equal('us-east-1'); }); it('should allow to override via `provider.region`', async () => { const { serverless } = await runServerless({ fixture: 'aws', command: 'print', configExt: { provider: { region: 'eu-central-1', }, }, }); expect(serverless.getProvider('aws').getRegion()).to.equal('eu-central-1'); }); it('should allow to override via CLI `--region` param', async () => { const { serverless } = await runServerless({ fixture: 'aws', command: 'print', options: { region: 'us-west-1' }, configExt: { provider: { region: 'eu-central-1', }, }, }); expect(serverless.getProvider('aws').getRegion()).to.equal('us-west-1'); }); });
In light of that, I've just removed this test file from the repository: 2e004eb
So, sorry you've taken an effort on that, but at least it moved us into right direction of removing this test file :)
|
sure @medikoo let me look further into this since I am also not confident about this approach. Let me look around and think a bit more if we are ok to remove these tests, or can modify them in a meaningful way given we already have similar tests in other places. |
Addresses: #2582
Refactor tests used in #11796
awsPlugin.options.stageandawsPlugin.provider.getStage()