Skip to content

Commit

Permalink
xSQLServerRole: Fix for issue #790 (#791)
Browse files Browse the repository at this point in the history
- Changes to xSQLServerRole
  - Running Get-DscConfiguration no longer throws an error saying property
    Members is not an array (issue #790).
  • Loading branch information
seizste authored and johlju committed Sep 7, 2017
1 parent 4278f70 commit de6a25b
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion DSCResources/MSFT_xSQLServerRole/MSFT_xSQLServerRole.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ function Get-TargetResource
{
try
{
$membersInRole = $sqlServerRoleObject.EnumMemberNames()
[System.String[]] $membersInRole = $sqlServerRoleObject.EnumMemberNames()
}
catch
{
Expand Down
40 changes: 40 additions & 0 deletions Tests/Unit/MSFT_xSQLServerRole.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit de6a25b

Please sign in to comment.