From c05115868ccccc4c061355227dfbf69bef00c5c2 Mon Sep 17 00:00:00 2001 From: Johan Ljunggren Date: Wed, 20 Sep 2017 10:37:32 +0200 Subject: [PATCH] xSQLServer: Fix integration tests. Added ErrorAction 'Stop' to the cmdlet Start-DscConfiguration (#826) - Changes to xSQLServerAlwaysOnService - Fix integration tests. Added ErrorAction 'Stop' to the cmdlet Start-DscConfiguration (issue #824]). - Changes to xSQLServerSetup - Fix integration tests. Added ErrorAction 'Stop' to the cmdlet Start-DscConfiguration (issue #824]). --- CHANGELOG.md | 4 +++ ...erverAlwaysOnService.Integration.Tests.ps1 | 27 ++++++++++----- ...MSFT_xSQLServerSetup.Integration.Tests.ps1 | 33 ++++++++++++------- 3 files changed, 45 insertions(+), 19 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0e53eb2ae..01fdc6676 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -46,6 +46,8 @@ more information in [issue #806](https://github.com/PowerShell/xFailOverCluster/issues/806)). - Fixed wrong variable name for SQL service credential. It was using the integration test variable name instead of the parameter name. + - Added ErrorAction 'Stop' to the cmdlet Start-DscConfiguration + ([issue #824](https://github.com/PowerShell/xSQLServer/issues/824)). - Changes to xSQLServerAlwaysOnAvailabilityGroup - Change the check of the values entered as parameter for BasicAvailabilityGroup. It is a boolean, hence it was not possible to @@ -71,6 +73,8 @@ find the specified property ([issue #801](https://github.com/PowerShell/xSQLServer/issues/801)) - Changes to xSQLServerAlwaysOnService - Added integration test ([issue #736](https://github.com/PowerShell/xSQLServer/issues/736)). + - Added ErrorAction 'Stop' to the cmdlet Start-DscConfiguration + ([issue #824](https://github.com/PowerShell/xSQLServer/issues/824)). - Added new resource xSQLServerAccount ([issue #706](https://github.com/PowerShell/xSQLServer/issues/706)) - Added localization support for all strings - Added examples for usage diff --git a/Tests/Integration/MSFT_xSQLServerAlwaysOnService.Integration.Tests.ps1 b/Tests/Integration/MSFT_xSQLServerAlwaysOnService.Integration.Tests.ps1 index 733c94558..43ea46858 100644 --- a/Tests/Integration/MSFT_xSQLServerAlwaysOnService.Integration.Tests.ps1 +++ b/Tests/Integration/MSFT_xSQLServerAlwaysOnService.Integration.Tests.ps1 @@ -44,14 +44,25 @@ try Context ('When using configuration {0}' -f $configurationName) { It 'Should compile and apply the MOF without throwing' { { - # The variable $ConfigurationData was dot-sourced above. - & $configurationName ` - -SqlInstallCredential $mockSqlInstallCredential ` - -OutputPath $TestDrive ` - -ConfigurationData $ConfigurationData - - Start-DscConfiguration -Path $TestDrive ` - -ComputerName localhost -Wait -Verbose -Force + $configurationParameters = @{ + SqlInstallCredential = $mockSqlInstallCredential + OutputPath = $TestDrive + # The variable $ConfigurationData was dot-sourced above. + ConfigurationData = $ConfigurationData + } + + & $configurationName @configurationParameters + + $startDscConfigurationParameters = @{ + Path = $TestDrive + ComputerName = 'localhost' + Wait = $true + Verbose = $true + Force = $true + ErrorAction = 'Stop' + } + + Start-DscConfiguration @startDscConfigurationParameters } | Should Not Throw } diff --git a/Tests/Integration/MSFT_xSQLServerSetup.Integration.Tests.ps1 b/Tests/Integration/MSFT_xSQLServerSetup.Integration.Tests.ps1 index b45035c88..d1ee07105 100644 --- a/Tests/Integration/MSFT_xSQLServerSetup.Integration.Tests.ps1 +++ b/Tests/Integration/MSFT_xSQLServerSetup.Integration.Tests.ps1 @@ -105,17 +105,28 @@ try Describe "$($script:DSCResourceName)_Integration" { It 'Should compile and apply the MOF without throwing' { { - # The variable $ConfigurationData was dot-sourced above. - & $configurationName ` - -SqlInstallCredential $mockSqlInstallCredential ` - -SqlAdministratorCredential $mockSqlAdminCredential ` - -SqlServiceCredential $mockSqlServiceCredential ` - -SqlAgentServiceCredential $mockSqlAgentServiceCredential ` - -OutputPath $TestDrive ` - -ConfigurationData $ConfigurationData - - Start-DscConfiguration -Path $TestDrive ` - -ComputerName localhost -Wait -Verbose -Force + $configurationParameters = @{ + SqlInstallCredential = $mockSqlInstallCredential + SqlAdministratorCredential = $mockSqlAdminCredential + SqlServiceCredential = $mockSqlServiceCredential + SqlAgentServiceCredential = $mockSqlAgentServiceCredential + OutputPath = $TestDrive + # The variable $ConfigurationData was dot-sourced above. + ConfigurationData = $ConfigurationData + } + + & $configurationName @configurationParameters + + $startDscConfigurationParameters = @{ + Path = $TestDrive + ComputerName = 'localhost' + Wait = $true + Verbose = $true + Force = $true + ErrorAction = 'Stop' + } + + Start-DscConfiguration @startDscConfigurationParameters } | Should Not Throw } -ErrorVariable itBlockError