Skip to content

Commit

Permalink
Changes to SqlSetup and SqlRS
Browse files Browse the repository at this point in the history
- Made the error message more descriptive when the Set-TargetResource
  function calls the Test-TargetResource function to verify the desired
  state.
  • Loading branch information
johlju committed Apr 25, 2019
1 parent 1f88754 commit c5fc049
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 6 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,20 @@
- Added additional unit tests for code coverage.
- Changes to SqlSetup
- Concatenated Robocopy localization strings ([issue #694](https://github.com/PowerShell/SqlServerDsc/issues/694)).
- Made the error message more descriptive when the Set-TargetResource
function calls the Test-TargetResource function to verify the desired
state.
- Changes to SqlWaitForAG
- Added en-US localization ([issue #625](https://github.com/PowerShell/SqlServerDsc/issues/625)).
- Changes to SqlServerPermission
- Added en-US localization ([issue #619](https://github.com/PowerShell/SqlServerDsc/issues/619)).
- Changes to SqlWindowsFirewall
- Added en-US localization ([issue #614](https://github.com/PowerShell/SqlServerDsc/issues/614)).
- Changes to SqlRS
- Fixed one of the error handling to use localization, and made the
error message more descriptive when the Set-TargetResource function
calls the Test-TargetResource function to verify the desired
state. *This was done prior to adding full en-US localization.*

## 12.4.0.0

Expand Down
5 changes: 4 additions & 1 deletion DSCResources/MSFT_SqlRS/MSFT_SqlRS.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ Import-Module -Name (Join-Path -Path $script:localizationModulePath -ChildPath '
$script:resourceHelperModulePath = Join-Path -Path $script:modulesFolderPath -ChildPath 'DscResource.Common'
Import-Module -Name (Join-Path -Path $script:resourceHelperModulePath -ChildPath 'DscResource.Common.psm1')

$script:localizedData = Get-LocalizedData -ResourceName 'MSFT_SqlWindowsFirewall'

<#
.SYNOPSIS
Gets the SQL Reporting Services initialization status.
Expand Down Expand Up @@ -670,7 +672,8 @@ function Set-TargetResource

if ( -not (Test-TargetResource @PSBoundParameters) )
{
throw New-TerminatingError -ErrorType TestFailedAfterSet -ErrorCategory InvalidResult
$errorMessage = $script:localizedData.TestFailedAfterSet
New-InvalidResultException -Message $errorMessage
}
}

Expand Down
3 changes: 3 additions & 0 deletions DSCResources/MSFT_SqlRS/en-US/MSFT_SqlRSSetup.strings.psd1
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ConvertFrom-StringData @'
TestFailedAfterSet = Test-TargetResource function returned false when Set-TargetResource function verified the desired state. This indicates that the Set-TargetResource did not correctly set set the desired state, or that the function Test-TargetResource does not correctly evaluates the desired state.
'@
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ ConvertFrom-StringData @'
SetupFailed = Please see the 'Summary.txt' log file in the 'Setup Bootstrap\\Log' folder.
Reboot = Rebooting target node.
SuppressReboot = Suppressing reboot of target node.
TestFailedAfterSet = Test-TargetResource returned false after calling Set-TargetResource.
TestFailedAfterSet = Test-TargetResource function returned false when Set-TargetResource function verified the desired state. This indicates that the Set-TargetResource did not correctly set set the desired state, or that the function Test-TargetResource does not correctly evaluates the desired state.
FeaturesFound = Found features already installed: {0}
NoFeaturesFound = No features are installed.
UnableToFindFeature = Unable to find feature '{0}' among the installed features: '{1}'.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ ConvertFrom-StringData @'
SetupFailed = Vänligen titta i loggfilen 'Summary.txt' i sökvägen 'Setup Bootstrap\\Log'.
Reboot = Startar om målnod.
SuppressReboot = Förhindrar omstart av målnod.
TestFailedAfterSet = Test-TargetResource retunerade falskt efter anropet till Set-TargetResource.
TestFailedAfterSet = Funktionen Test-TargetResource returnerade falskt när funktionen Set-TargetResource verifierade önskad konfiguration. Detta indikerar att funktionen Set-TargetResource inte på ett korrekt sätt kunde sätta önskad konfiguration, eller att funktionen Test-TargetResource inte utvärderar önskad konfiguration på korrekt sätt.
FeaturesFound = Funktioner funna: {0}
UnableToFindFeature = Kunde inte hitta funktion '{0}' bland som installerade funktionerna: '{1}'.
EvaluatingClusterParameters = Klustrad installation, kontrollerar parametrar.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ ConvertFrom-StringData @'
# Common
NoKeyFound = No Localization key found for ErrorType: '{0}'.
AbsentNotImplemented = Ensure = Absent is not implemented!
TestFailedAfterSet = Test-TargetResource returned false after calling set.
RemoteConnectionFailed = Remote PowerShell connection to Server '{0}' failed.
TODO = ToDo. Work not implemented at this time.
UnexpectedErrorFromGet = Got unexpected result from Get-TargetResource. No change is made.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ ConvertFrom-StringData @'
# Common
NoKeyFound = No Localization key found for ErrorType: '{0}'.
AbsentNotImplemented = Ensure = Absent is not implemented!
TestFailedAfterSet = Test-TargetResource returned false after calling set.
RemoteConnectionFailed = Remote PowerShell connection to Server '{0}' failed.
TODO = ToDo. Work not implemented at this time.
UnexpectedErrorFromGet = Got unexpected result from Get-TargetResource. No change is made.
Expand Down
2 changes: 1 addition & 1 deletion Tests/Unit/MSFT_SqlRS.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ try
}

It 'Should throw the correct error message' {
{ Set-TargetResource @defaultParameters } | Should -Throw 'Test-TargetResource returned false after calling set.'
{ Set-TargetResource @defaultParameters } | Should -Throw $script:localizedData.TestFailedAfterSet
}
}

Expand Down

0 comments on commit c5fc049

Please sign in to comment.