diff --git a/Tests/Unit/MSFT_SqlRS.Tests.ps1 b/Tests/Unit/MSFT_SqlRS.Tests.ps1 index f52f6e850..7b7b06a42 100644 --- a/Tests/Unit/MSFT_SqlRS.Tests.ps1 +++ b/Tests/Unit/MSFT_SqlRS.Tests.ps1 @@ -532,105 +532,106 @@ try Assert-MockCalled -CommandName Get-CimInstance -Exactly -Times 1 -Scope It Assert-MockCalled -CommandName Invoke-Sqlcmd -Exactly -Times 0 -Scope It - Assert-MockCalled -CommandName Restart-ReportingServicesService -Exactly -Times 1 -Scope It + Assert-MockCalled -CommandName Restart-ReportingServicesService -Exactly -Times 1 -Scope It } } - Context 'When configuring a named instance that are already initialized, suppress restart' { - BeforeAll { - $mockDynamic_SqlBuildVersion = '13.0.4001.0' - $mockDynamicIsInitialized = $true + Context "When configuring a named instance that are already initialized ($($sqlVersion.VersionName)), suppress restart" { + BeforeAll { + $mockDynamicIsInitialized = $true - Mock -CommandName Get-TargetResource -MockWith { - return @{ - ReportServerReservedUrl = $mockReportServerApplicationUrl - ReportsReservedUrl = $mockReportsApplicationUrl + Mock -CommandName Get-ReportingServicesData -MockWith { + return @{ + Configuration = (& $mockGetCimInstance_ConfigurationSetting_NamedInstance)[0] + ReportsApplicationName = 'ReportServerWebApp' + SqlVersion = $sqlVersion.Version + } } - } - Mock -CommandName Test-TargetResource -MockWith { - return $true - } + Mock -CommandName Get-TargetResource -MockWith { + return @{ + ReportServerReservedUrl = $mockReportServerApplicationUrl + ReportsReservedUrl = $mockReportsApplicationUrl + } + } - $testParameters = @{ - InstanceName = $mockNamedInstanceName - DatabaseServerName = $mockReportingServicesDatabaseServerName - DatabaseInstanceName = $mockReportingServicesDatabaseNamedInstanceName - ReportServerVirtualDirectory = 'ReportServer_NewName' - ReportsVirtualDirectory = 'Reports_NewName' - ReportServerReservedUrl = 'https://+:4443' - ReportsReservedUrl = 'https://+:4443' - UseSsl = $true - SuppressRestart = $true + Mock -CommandName Test-TargetResource -MockWith { + return $true + } + + $testParameters = @{ + InstanceName = $mockNamedInstanceName + DatabaseServerName = $mockReportingServicesDatabaseServerName + DatabaseInstanceName = $mockReportingServicesDatabaseNamedInstanceName + ReportServerVirtualDirectory = 'ReportServer_NewName' + ReportsVirtualDirectory = 'Reports_NewName' + ReportServerReservedUrl = 'https://+:4443' + ReportsReservedUrl = 'https://+:4443' + UseSsl = $true + SuppressRestart = $true + } } - } - BeforeEach { - Mock -CommandName Get-CimInstance ` - -MockWith $mockGetCimInstance_ConfigurationSetting_NamedInstance ` - -ParameterFilter $mockGetCimInstance_ConfigurationSetting_ParameterFilter ` - -Verifiable - - Mock -CommandName Get-CimInstance ` - -MockWith $mockGetCimInstance_Language ` - -ParameterFilter $mockGetCimInstance_OperatingSystem_ParameterFilter ` - -Verifiable - } + BeforeEach { + Mock -CommandName Get-CimInstance ` + -MockWith $mockGetCimInstance_Language ` + -ParameterFilter $mockGetCimInstance_OperatingSystem_ParameterFilter + } - It 'Should configure Reporting Service without throwing an error' { - { Set-TargetResource @testParameters } | Should -Not -Throw + It 'Should configure Reporting Service without throwing an error' { + { Set-TargetResource @testParameters } | Should -Not -Throw - Assert-MockCalled -CommandName Invoke-RsCimMethod -ParameterFilter { - $MethodName -eq 'SetSecureConnectionLevel' - } -Exactly -Times 1 -Scope It + Assert-MockCalled -CommandName Invoke-RsCimMethod -ParameterFilter { + $MethodName -eq 'SetSecureConnectionLevel' + } -Exactly -Times 1 -Scope It - Assert-MockCalled -CommandName Invoke-RsCimMethod -ParameterFilter { - $MethodName -eq 'RemoveURL' -and $Arguments.Application -eq $mockReportServerApplicationName - } -Exactly -Times 2 -Scope It + Assert-MockCalled -CommandName Invoke-RsCimMethod -ParameterFilter { + $MethodName -eq 'RemoveURL' -and $Arguments.Application -eq $mockReportServerApplicationName + } -Exactly -Times 2 -Scope It - Assert-MockCalled -CommandName Invoke-RsCimMethod -ParameterFilter { - $MethodName -eq 'RemoveURL' -and $Arguments.Application -eq $mockReportsApplicationName - } -Exactly -Times 2 -Scope It + Assert-MockCalled -CommandName Invoke-RsCimMethod -ParameterFilter { + $MethodName -eq 'RemoveURL' -and $Arguments.Application -eq $mockReportsApplicationName + } -Exactly -Times 2 -Scope It - Assert-MockCalled -CommandName Invoke-RsCimMethod -ParameterFilter { - $MethodName -eq 'InitializeReportServer' - } -Exactly -Times 0 -Scope It + Assert-MockCalled -CommandName Invoke-RsCimMethod -ParameterFilter { + $MethodName -eq 'InitializeReportServer' + } -Exactly -Times 0 -Scope It - Assert-MockCalled -CommandName Invoke-RsCimMethod -ParameterFilter { - $MethodName -eq 'SetDatabaseConnection' - } -Exactly -Times 0 -Scope It + Assert-MockCalled -CommandName Invoke-RsCimMethod -ParameterFilter { + $MethodName -eq 'SetDatabaseConnection' + } -Exactly -Times 0 -Scope It - Assert-MockCalled -CommandName Invoke-RsCimMethod -ParameterFilter { - $MethodName -eq 'GenerateDatabaseRightsScript' - } -Exactly -Times 0 -Scope It + Assert-MockCalled -CommandName Invoke-RsCimMethod -ParameterFilter { + $MethodName -eq 'GenerateDatabaseRightsScript' + } -Exactly -Times 0 -Scope It - Assert-MockCalled -CommandName Invoke-RsCimMethod -ParameterFilter { - $MethodName -eq 'GenerateDatabaseCreationScript' - } -Exactly -Times 0 -Scope It + Assert-MockCalled -CommandName Invoke-RsCimMethod -ParameterFilter { + $MethodName -eq 'GenerateDatabaseCreationScript' + } -Exactly -Times 0 -Scope It - Assert-MockCalled -CommandName Invoke-RsCimMethod -ParameterFilter { - $MethodName -eq 'SetVirtualDirectory' -and $Arguments.Application -eq $mockReportServerApplicationName - } -Exactly -Times 1 -Scope It + Assert-MockCalled -CommandName Invoke-RsCimMethod -ParameterFilter { + $MethodName -eq 'SetVirtualDirectory' -and $Arguments.Application -eq $mockReportServerApplicationName + } -Exactly -Times 1 -Scope It - Assert-MockCalled -CommandName Invoke-RsCimMethod -ParameterFilter { - $MethodName -eq 'SetVirtualDirectory' -and $Arguments.Application -eq $mockReportsApplicationName - } -Exactly -Times 1 -Scope It + Assert-MockCalled -CommandName Invoke-RsCimMethod -ParameterFilter { + $MethodName -eq 'SetVirtualDirectory' -and $Arguments.Application -eq $mockReportsApplicationName + } -Exactly -Times 1 -Scope It - Assert-MockCalled -CommandName Invoke-RsCimMethod -ParameterFilter { - $MethodName -eq 'ReserveUrl' -and $Arguments.Application -eq $mockReportServerApplicationName - } -Exactly -Times 2 -Scope It + Assert-MockCalled -CommandName Invoke-RsCimMethod -ParameterFilter { + $MethodName -eq 'ReserveUrl' -and $Arguments.Application -eq $mockReportServerApplicationName + } -Exactly -Times 2 -Scope It - Assert-MockCalled -CommandName Invoke-RsCimMethod -ParameterFilter { - $MethodName -eq 'ReserveUrl' -and $Arguments.Application -eq $mockReportsApplicationName - } -Exactly -Times 2 -Scope It + Assert-MockCalled -CommandName Invoke-RsCimMethod -ParameterFilter { + $MethodName -eq 'ReserveUrl' -and $Arguments.Application -eq $mockReportsApplicationName + } -Exactly -Times 2 -Scope It - Assert-MockCalled -CommandName Get-CimInstance -Exactly -Times 2 -Scope It - Assert-MockCalled -CommandName Invoke-Sqlcmd -Exactly -Times 0 -Scope It - Assert-MockCalled -CommandName Restart-ReportingServicesService -Exactly -Times 0 -Scope It + Assert-MockCalled -CommandName Get-CimInstance -Exactly -Times 1 -Scope It + Assert-MockCalled -CommandName Invoke-Sqlcmd -Exactly -Times 0 -Scope It + Assert-MockCalled -CommandName Restart-ReportingServicesService -Exactly -Times 0 -Scope It + } } - } - Context "When configuring a default instance that are not initialized ($($sqlVersion.VersionName))" { + Context "When configuring a default instance that are not initialized ($($sqlVersion.VersionName))" { BeforeAll { $mockDynamicIsInitialized = $false