Skip to content

Commit

Permalink
Changes to xSQLServerRSConfig
Browse files Browse the repository at this point in the history
- No longer returns a null value from Test-TargetResource when Reporting
  Services has not been initialized (issue dsccommunity#822).
  • Loading branch information
johlju committed Sep 19, 2017
1 parent b2e553b commit b22aa04
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@
- Added new resource xSQLServerAccount ([issue #706](https://github.com/PowerShell/xSQLServer/issues/706))
- Added localization support for all strings
- Added examples for usage
- Changes to xSQLServerRSConfig
- No longer returns a null value from Test-TargetResource when Reporting
Services has not been initialized ([issue #822](https://github.com/PowerShell/xSQLServer/issues/822)).

## 8.1.0.0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ function Get-TargetResource
$RSSQLInstanceName = 'MSSQLSERVER'
}

$isInitialized = $reportingServicesConfiguration.IsInitialized
[System.Boolean] $isInitialized = $reportingServicesConfiguration.IsInitialized
}
else
{
Expand Down
20 changes: 17 additions & 3 deletions Tests/Unit/MSFT_xSQLServerRSConfig.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ try
$mockGetWmiObject_ConfigurationSetting_NamedInstance = {
return New-Object Object |
Add-Member -MemberType NoteProperty -Name 'DatabaseServerName' -Value "$mockReportingServicesDatabaseServerName\$mockReportingServicesDatabaseNamedInstanceName" -PassThru |
Add-Member -MemberType NoteProperty -Name 'IsInitialized' -Value $true -PassThru |
Add-Member -MemberType NoteProperty -Name 'IsInitialized' -Value $mockDynamicIsInitialized -PassThru |
Add-Member -MemberType NoteProperty -Name 'VirtualDirectoryReportServer' -Value '' -PassThru |
Add-Member -MemberType NoteProperty -Name 'VirtualDirectoryReportManager' -Value '' -PassThru |
Add-Member -MemberType ScriptMethod -Name SetVirtualDirectory {
Expand Down Expand Up @@ -92,7 +92,7 @@ try
$mockGetWmiObject_ConfigurationSetting_DefaultInstance = {
return @{
DatabaseServerName = $mockReportingServicesDatabaseServerName
IsInitialized = $false
IsInitialized = $mockDynamicIsInitialized
}
}

Expand Down Expand Up @@ -131,6 +131,8 @@ try
-Verifiable
}

$mockDynamicIsInitialized = $true

It 'Should return the same values as passed as parameters' {
$resultGetTargetResource = Get-TargetResource @testParameters
$resultGetTargetResource.InstanceName | Should Be $mockNamedInstanceName
Expand All @@ -153,6 +155,8 @@ try
-Verifiable
}

$mockDynamicIsInitialized = $false

It 'Should return the same values as passed as parameters' {
$resultGetTargetResource = Get-TargetResource @testParameters
$resultGetTargetResource.InstanceName | Should Be $mockNamedInstanceName
Expand All @@ -161,11 +165,21 @@ try
$resultGetTargetResource | Should BeOfType [System.Collections.Hashtable]
}

It 'Should return the the state as initialized' {
It 'Should return the state as not initialized' {
$resultGetTargetResource = Get-TargetResource @testParameters
$resultGetTargetResource.IsInitialized | Should Be $false
}

# Regression test for issue #822.
Context 'When Reporting Services has not been initialized (IsInitialized returns $null)' {
$mockDynamicIsInitialized = $null

It 'Should return the state as not initialized' {
$resultGetTargetResource = Get-TargetResource @testParameters
$resultGetTargetResource.IsInitialized | Should Be $false
}
}

Context 'When there is no Reporting Services instance' {
BeforeEach {
Mock -CommandName Get-ItemProperty
Expand Down

0 comments on commit b22aa04

Please sign in to comment.