diff --git a/CHANGELOG.md b/CHANGELOG.md index 0888a7eb5..770164556 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,9 @@ - Add possibility to enable the feature DtcSupportEnabled (SQL Server 2016 or later only). The feature currently can't be altered once the Availability Group is created. + - Changes to xSQLServerRole + - Running Get-DscConfiguration no longer throws an error saying property + Members is not an array ([Issue #790](https://github.com/PowerShell/xSQLServer/issues/790)). ## 8.1.0.0 diff --git a/DSCResources/MSFT_xSQLServerRole/MSFT_xSQLServerRole.psm1 b/DSCResources/MSFT_xSQLServerRole/MSFT_xSQLServerRole.psm1 index 18c41b3da..8c01065db 100644 --- a/DSCResources/MSFT_xSQLServerRole/MSFT_xSQLServerRole.psm1 +++ b/DSCResources/MSFT_xSQLServerRole/MSFT_xSQLServerRole.psm1 @@ -67,7 +67,7 @@ function Get-TargetResource { try { - $membersInRole = $sqlServerRoleObject.EnumMemberNames() + [System.String[]] $membersInRole = $sqlServerRoleObject.EnumMemberNames() } catch { diff --git a/Tests/Unit/MSFT_xSQLServerRole.Tests.ps1 b/Tests/Unit/MSFT_xSQLServerRole.Tests.ps1 index 9237e198c..83bf2e3a5 100644 --- a/Tests/Unit/MSFT_xSQLServerRole.Tests.ps1 +++ b/Tests/Unit/MSFT_xSQLServerRole.Tests.ps1 @@ -212,6 +212,14 @@ try Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It } + # Regression test for issue #790 + It 'Should return the members as string array' { + $result = Get-TargetResource @testParameters + ($result.Members -is [String[]]) | Should Be $true + + Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It + } + It 'Should return the same values as passed as parameters' { $result = Get-TargetResource @testParameters $result.SQLServer | Should Be $testParameters.SQLServer @@ -264,6 +272,14 @@ try Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It } + # Regression test for issue #790 + It 'Should return the members as string array' { + $result = Get-TargetResource @testParameters + ($result.Members -is [String[]]) | Should Be $true + + Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It + } + It 'Should return the same values as passed as parameters' { $result = Get-TargetResource @testParameters $result.SQLServer | Should Be $testParameters.SQLServer @@ -295,6 +311,14 @@ try Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It } + # Regression test for issue #790 + It 'Should return the members as string array' { + $result = Get-TargetResource @testParameters + ($result.Members -is [String[]]) | Should Be $true + + Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It + } + It 'Should return the same values as passed as parameters' { $result = Get-TargetResource @testParameters $result.SQLServer | Should Be $testParameters.SQLServer @@ -425,6 +449,14 @@ try Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It } + # Regression test for issue #790 + It 'Should return the members as string array' { + $result = Get-TargetResource @testParameters + ($result.Members -is [String[]]) | Should Be $true + + Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It + } + It 'Should return the same values as passed as parameters' { $result = Get-TargetResource @testParameters $result.SQLServer | Should Be $testParameters.SQLServer @@ -456,6 +488,14 @@ try Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It } + # Regression test for issue #790 + It 'Should return the members as string array' { + $result = Get-TargetResource @testParameters + ($result.Members -is [String[]]) | Should Be $true + + Assert-MockCalled Connect-SQL -Exactly -Times 1 -Scope It + } + It 'Should return the same values as passed as parameters' { $result = Get-TargetResource @testParameters $result.SQLServer | Should Be $testParameters.SQLServer