-
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
xSQLServerAlwaysOnAvailabilityGroup: Should use the correct major version SQLPS stubs for unit tests #784
Comments
Maybe add a test helper function that loads the removes SQLPS stubs module and reloads the correct SQLPS stubs module. Making sure the correct one is in the session, so it can be reused in other tests. |
@johlju, do any of the other modules switch the stubs that are used based on the version of SQL being used? |
You mean the other resources in this module? No, but I think they should. We should also have another stub file for SqlServer module as well. |
Do we need to add a test helper file for this project's tests that will aid with this? If so, where would we store it? I'm thinking |
Yes. And I suggest you use the same path and filename as here. The helper functions in this should be moved over here later as well (another issue), but then we have the file already present to add the helper functions to. :) |
Suggested function name: Import-SQLModuleStub |
Ok, working this into my updates for issue #468. |
Awesome! The function name works for me. |
- Changes to xSQLServerAlwaysOnAvailabilityGroup - Refactored the unit tests to allow them to be more user friendly and to test additional SQLServer variations. - Each test will utilize the Import-SQLModuleStub to ensure the correct module is loaded (issue #784). - Fixed an issue when setting the SQLServer parameter to a Fully Qualified Domain Name (FQDN) (issue #468). - Fixed the logic so that if a parameter is not supplied to the resource, the resource will not attempt to apply the defaults on subsequent checks (issue #517). - Added the CommonTestHelper.psm1 to store common testing functions. - Added the Import-SQLModuleStub function to ensure the correct version of the module stubs are loaded (issue #784).
Details of the scenario you tried and the problem that is occurring:
When running unit test for xSQLServerAlwaysOnAvailabilityGroup it should use SQLPS stubs from SQL Server 2014 when major version is 12, and SQLPS stubs from SQL Server 2016 when major version is 13. This would actually test so parameters are not used that are not supported in older versions.
https://github.com/PowerShell/xSQLServer/blob/c290c0074ad34a1a5649b25a475f850008e525f3/Tests/Unit/MSFT_xSQLServerAlwaysOnAvailabilityGroup.Tests.ps1#L86-L88
Currently parameters are added to the existing SQLPS stubs making such test impossible. See for example the stub for
New-SqlAvailabilityGroup
which contains parameters not in SQL Server 2014.The DSC configuration that is using the resource (as detailed as possible):
n/a
Version of the Operating System, SQL Server and PowerShell the DSC Target Node is running:
n/a
What module (SqlServer or SQLPS) and which version of the module the DSC Target Node is running:
SQLPS
Version of the DSC module you're using, or 'dev' if you're using current dev branch:
Dev
The text was updated successfully, but these errors were encountered: