-
Notifications
You must be signed in to change notification settings - Fork 225
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
Additional tests, and some fixes, related to AlwaysOn #98
Additional tests, and some fixes, related to AlwaysOn #98
Conversation
Small changes to previous test xSQLServerPermission
Removed global scope on `Import-Module` for the mocked SQLPS module (MockSQLPS)
Also - Cleanup in test for xSQLServerEndpointState - Improved xSQLServerPermission to test for Revoke() as well
This fixes issues dsccommunity#94
This fixes issue dsccommunity#96 in xSQLServerAvailibilityGroupListener
Fixed DHCP issue dsccommunity#95. Now the resource will throw 'Not supported' when IP is changed between Static and DHCP.
Hi @johlju, I'm your friendly neighborhood Microsoft Pull Request Bot (You can call me MSBOT). Thanks for your contribution! The agreement was validated by Microsoft and real humans are currently evaluating your PR. TTYL, MSBOT; |
What is the test that fails without a fake function? |
See the block |
If I remove this block
I get this error
|
@johlju OK, so I followed Pester's code and you are correct, the command cannot be resolved (since the SqlServer module is not installed when the UTs run). Your solution will make things work, but I think there should be a comment explaining why the mock module is there. Some suggestions you may want to consider:
|
@narrieta That's actually genius - we do the PSM1 file for SharePointDsc but we don't throw inside the calls, we just use them to create our mocks from. I might need to alter my script which generates those stubs to add the exception call in. |
@kwirkykat No, those issues in the test run for PR #89 got to do with an issue with the testing framework, see @mbreakey3 and our comments about the problem in issue #92. Maybe when this PR is merged, and then @aultt resolve conflicts for #89 it might auto heal? |
@narrieta I will change so that it used a stub module instead, and that the functions in the stub throws, as per your suggestion. |
@johlju looks like you have a pending review can you acknowledge so this can be merged? Waiting on your changes so my PR can go. |
@aultt I'm working on the code change which is 90% done, I will try to commit it to the PR tomorrow night (Sweden time). Otherwise on Friday evening. (I'm currently away in another city so have limited time to code :/ ) |
@johlju sounds good Ill take a look next week. |
And added comments from where the stubs were generated
Bug in xSQLServerAvailabilityGroupListener when trying to add a static IP to a listener
Review status: 0 of 10 files reviewed at latest revision, 1 unresolved discussion, some commit checks failed. Tests/Unit/Stubs/SQLServerStub.psm1, line 0 [r3] (raw file): Comments from Reviewable |
# Suppressing this rule because these functions are from an external module
# and are only being used as stubs
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingUserNameAndPassWordParams', '')]
param() |
Suppressing this rule because these functions are from an external module and are only being used as stubs
Reviewed 1 of 8 files at r1. README.md, line 345 [r3] (raw file):
Move these comments under 'Unreleased' - I think it got messed up when we released on Wed. DSCResources/xSQLServerAvailabilityGroupListener/xSQLServerAvailabilityGroupListener.psm1, line 288 [r3] (raw file):
can you divide up this line so that each 'and' is on its own line? Tests/Unit/xSQLServerAvailabilityGroupListener.Tests.ps1, line 50 [r3] (raw file):
You can remove this block if you're not using it Tests/Unit/xSQLServerAvailabilityGroupListener.Tests.ps1, line 90 [r3] (raw file):
Again - this can be removed Tests/Unit/xSQLServerAvailabilityGroupListener.Tests.ps1, line 99 [r3] (raw file):
Can you declare each of these hard coded numbers (port, ipAddress, subnetMask) as variables at the top of the test? Tests/Unit/xSQLServerAvailabilityGroupListener.Tests.ps1, line 143 [r3] (raw file):
Remove Tests/Unit/xSQLServerAvailabilityGroupListener.Tests.ps1, line 201 [r3] (raw file):
remove Tests/Unit/xSQLServerAvailabilityGroupListener.Tests.ps1, line 209 [r3] (raw file):
Create variable for hard-coded values Tests/Unit/xSQLServerAvailabilityGroupListener.Tests.ps1, line 260 [r3] (raw file):
When you're using the same mock in multiple It statements or context blocks you can just declare once at the top of the Describe block Tests/Unit/xSQLServerAvailabilityGroupListener.Tests.ps1, line 292 [r3] (raw file):
Since you have some of these where IsDHCP is set to false and some where it's set to true, divide those into two different 'Context' blocks and declare the mock at the top of each and then include each 'It' statement that uses that particular Mock in that 'Context' block. Alternatively, you could set a [Bool] $mockDHCP variable at the top of the Describe block and then just change that value for each 'It' rather than declaring the mock over and over. Tests/Unit/xSQLServerAvailabilityGroupListener.Tests.ps1, line 469 [r3] (raw file):
remove Comments from Reviewable |
Review status: 1 of 10 files reviewed at latest revision, 12 unresolved discussions. Tests/Unit/xSQLServerAvailabilityGroupListener.Tests.ps1, line 99 [r3] (raw file):
|
Review status: 1 of 10 files reviewed at latest revision, 12 unresolved discussions, some commit checks failed. README.md, line 345 [r3] (raw file):
|
Review status: 1 of 10 files reviewed at latest revision, 12 unresolved discussions. Tests/Unit/xSQLServerAvailabilityGroupListener.Tests.ps1, line 99 [r3] (raw file):
|
Reviewed 2 of 8 files at r4. Tests/Unit/xSQLServerAvailabilityGroupListener.Tests.ps1, line 99 [r3] (raw file):
|
Review status: 3 of 10 files reviewed at latest revision, 6 unresolved discussions, some commit checks failed. Tests/Unit/xSQLServerAvailabilityGroupListener.Tests.ps1, line 99 [r3] (raw file):
|
Review status: 3 of 10 files reviewed at latest revision, 6 unresolved discussions, some commit checks failed. Tests/Unit/xSQLServerAvailabilityGroupListener.Tests.ps1, line 99 [r3] (raw file):
|
Also reverting back changes that didn't work when trying to use local variables in mocks
Congrats @johlju Looks like the build worked!!! |
Review status: 3 of 10 files reviewed at latest revision, 6 unresolved discussions. Tests/Unit/xSQLServerAvailabilityGroupListener.Tests.ps1, line 99 [r3] (raw file):
|
@aultt Yes, it worked first time around too... :) Tried to get local variables to work in mocks, as per suggestion of @mbreakey3. That did not work out to well, that's why it failed. Reverted back to hardcoded values again to get AppVeyor happy. :D |
Tests/Unit/xSQLServerAvailabilityGroupListener.Tests.ps1, line 41 [r4] (raw file):
|
Reviewed 1 of 8 files at r1, 2 of 8 files at r4. Tests/Unit/Stubs/SQLServerStub.psm1, line [r3] (raw file):
|
Tests/Unit/xSQLServerAvailabilityGroupListener.Tests.ps1, line 41 [r4] (raw file):
|
Review status: 6 of 10 files reviewed at latest revision, 6 unresolved discussions, some commit checks failed. Comments from Reviewable |
Reviewed 2 of 8 files at r4, 2 of 2 files at r5, 1 of 1 files at r6. Comments from Reviewable |
I'm going to merge this for now, since all of the functionality looks good. We can work on the test formatting later once we have a solid workaround. Comments from Reviewable |
Review status: all files reviewed at latest revision, 2 unresolved discussions. Tests/Unit/xSQLServerAvailabilityGroupListener.Tests.ps1, line 41 [r4] (raw file):
|
This change is