diff --git a/CHANGELOG.md b/CHANGELOG.md index 8fd00d8fc1..fe76c11419 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - `SqlAgentAlert` - Minor fix in `source/Classes/020.SqlAgentAlert.ps1` to correct `ExcludeDscProperties` formatting (added missing delimiter). +- `SqlRSSetup` + - Re-added `ReportServerEdition` enum and updated class to use enum instead of + ValidateSet for the Edition property. ### Added diff --git a/source/Classes/020.SqlRSSetup.ps1 b/source/Classes/020.SqlRSSetup.ps1 index 389f439472..27a4289734 100644 --- a/source/Classes/020.SqlRSSetup.ps1 +++ b/source/Classes/020.SqlRSSetup.ps1 @@ -187,8 +187,7 @@ class SqlRSSetup : ResourceBase $EditionUpgrade [DscProperty()] - [ValidateSet('Developer', 'Evaluation', 'ExpressAdvanced')] - [System.String] + [ReportServerEdition] $Edition [DscProperty()] @@ -402,8 +401,9 @@ class SqlRSSetup : ResourceBase hidden [void] Modify([System.Collections.Hashtable] $properties) { $getDscPropertyParameters = @{ - HasValue = $true - Attribute = @( + HasValue = $true + IgnoreZeroEnumValue = $true + Attribute = @( 'Optional' 'Mandatory' ) diff --git a/source/Enum/001.ReportServerEdition.ps1 b/source/Enum/001.ReportServerEdition.ps1 new file mode 100644 index 0000000000..0d0588e561 --- /dev/null +++ b/source/Enum/001.ReportServerEdition.ps1 @@ -0,0 +1,12 @@ +<# + .SYNOPSIS + The possible states for the commands and DSC resources that handles + SQL Server Reporting Services or Power BI Report Server and uses the + parameter Edition. +#> +enum ReportServerEdition +{ + Developer = 1 + Evaluation + ExpressAdvanced +} diff --git a/tests/Unit/Classes/SqlRSSetup.Tests.ps1 b/tests/Unit/Classes/SqlRSSetup.Tests.ps1 index bb54e621ac..2278d2d278 100644 --- a/tests/Unit/Classes/SqlRSSetup.Tests.ps1 +++ b/tests/Unit/Classes/SqlRSSetup.Tests.ps1 @@ -129,7 +129,8 @@ Describe 'SqlRSSetup\Get()' -Tag 'Get' { $currentState.MediaPath | Should -BeNullOrEmpty $currentState.ProductKey | Should -BeNullOrEmpty $currentState.EditionUpgrade | Should -BeNullOrEmpty - $currentState.Edition | Should -BeNullOrEmpty + # Returns 0, that means no value was set by GetCurrentState() from the enum ReportServerEdition + $currentState.Edition | Should -Be 0 $currentState.LogPath | Should -BeNullOrEmpty $currentState.InstallFolder | Should -BeNullOrEmpty $currentState.SuppressRestart | Should -BeFalse @@ -187,7 +188,8 @@ Describe 'SqlRSSetup\Get()' -Tag 'Get' { $currentState.MediaPath | Should -BeNullOrEmpty $currentState.ProductKey | Should -BeNullOrEmpty $currentState.EditionUpgrade | Should -BeNullOrEmpty - $currentState.Edition | Should -BeNullOrEmpty + # Returns 0, that means no value was set by GetCurrentState() from the enum ReportServerEdition + $currentState.Edition | Should -Be 0 $currentState.LogPath | Should -BeNullOrEmpty $currentState.InstallFolder | Should -BeNullOrEmpty $currentState.SuppressRestart | Should -BeFalse