Skip to content

Commit

Permalink
SqlRSSetup: Fix SuppressRestart to not be added when $false (#1673)
Browse files Browse the repository at this point in the history
- SqlRSSetup
  - If parameter `SuppressRestart` is set to `$false` the `/norestart`
    argument is no longer wrongly added (issue #1401).
  • Loading branch information
johlju committed Jan 21, 2021
1 parent a6b8db8 commit c392042
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Updated `SqlLogin`, integration tests to make use of amended `Wait-ForIdleLcm`,
helper function, `-Clear` switch usage to remove intermittent, integration
test failures ([issue #1634](https://github.com/dsccommunity/SqlServerDsc/issues/1634)).
- SqlRSSetup
- If parameter `SuppressRestart` is set to `$false` the `/norestart`
argument is no longer wrongly added ([issue #1401](https://github.com/dsccommunity/SqlServerDsc/issues/1401)).

## [15.0.1] - 2021-01-09

Expand Down
7 changes: 5 additions & 2 deletions source/DSCResources/DSC_SqlRSSetup/DSC_SqlRSSetup.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -397,8 +397,11 @@ function Set-TargetResource

'SuppressRestart'
{
$setupArguments += @{
'norestart' = [System.Management.Automation.SwitchParameter] $true
if ($SuppressRestart -eq $true)
{
$setupArguments += @{
'norestart' = [System.Management.Automation.SwitchParameter] $true
}
}
}

Expand Down
29 changes: 28 additions & 1 deletion tests/Unit/DSC_SqlRSSetup.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,33 @@ try
}
}

Context 'When Reporting Services are installed with parameter SuppressRestart set to $false' {
BeforeEach {
$mockSetTargetResourceParameters['ProductKey'] = $mockProductKey
$mockSetTargetResourceParameters['SuppressRestart'] = $false

$mockStartSqlSetupProcess_ExpectedArgumentList = @{
Quiet = [System.Management.Automation.SwitchParameter] $true
IAcceptLicenseTerms = [System.Management.Automation.SwitchParameter] $true
PID = $mockProductKey
}

Mock -CommandName Start-SqlSetupProcess -MockWith {
Test-SetupArgument -Argument $ArgumentList -ExpectedArgument $mockStartSqlSetupProcess_ExpectedArgumentList

return 0
}
}

It 'Should call the correct mock with the expected arguments' {
{ Set-TargetResource @mockSetTargetResourceParameters } | Should -Not -Throw

Assert-MockCalled -CommandName Start-SqlSetupProcess -ParameterFilter {
$FilePath -eq $mockSetTargetResourceParameters.SourcePath
} -Exactly -Times 1 -Scope 'It'
}
}

Context 'When Reporting Services are installed with parameters EditionUpgrade set to $false' {
BeforeEach {
$mockSetTargetResourceParameters['ProductKey'] = $mockProductKey
Expand Down Expand Up @@ -681,7 +708,7 @@ try

Context 'When Reporting Services are installed using parameter SourceCredential' {
BeforeAll {
$mockLocalPath = 'C:\LocalPath'
$mockLocalPath = Join-Path -Path $TestDrive - -ChildPath 'LocalPath'

$mockShareCredentialUserName = 'COMPANY\SqlAdmin'
$mockShareCredentialPassword = 'dummyPassW0rd'
Expand Down

0 comments on commit c392042

Please sign in to comment.