Skip to content

Commit

Permalink
SqlServerDsc: Re-enable Pester's new code coverage method (#1857)
Browse files Browse the repository at this point in the history
- SqlServerDsc
  - Add empty constructor to classes to be able to use Pester's new code
    coverage method. See more information can be found in [pester/Pester#2306]
  • Loading branch information
johlju authored Feb 25, 2023
1 parent 38a0da4 commit f6ce795
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
is loaded into the session. This will make it possible for classes and
commands to use and return SQL types. If no module is found it will
output a warning to install any of the dependent modules.
- Add empty constructor to classes to be able to use Pester's new code
coverage method. See more information can be found in [pester/Pester#2306](https://github.com/pester/Pester/issues/2306).
- `Install-SqlServerDsc`
- No longer throws an exception when parameter `AgtSvcAccount` is not specified.
- SqlAgReplica
Expand Down
4 changes: 1 addition & 3 deletions build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,7 @@ Pester:
CoveragePercentTarget: 85
OutputPath: JaCoCo_coverage.xml
OutputEncoding: ascii
# There is a bug in Pester when running unit tests for classes when 'UseBreakpoints' is turned off.
# See error in gist: https://gist.github.com/johlju/c16dfd9587c7e066e8825fc54b33a703
UseBreakpoints: true
UseBreakpoints: false
TestResult:
OutputFormat: NUnitXML
OutputEncoding: ascii
Expand Down
4 changes: 4 additions & 0 deletions source/Classes/002.DatabasePermission.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ class DatabasePermission : IComparable, System.IEquatable[Object]
[System.String[]]
$Permission

DatabasePermission ()
{
}

[System.Boolean] Equals([System.Object] $object)
{
$isEqual = $false
Expand Down
5 changes: 5 additions & 0 deletions source/Classes/002.ServerPermission.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ class ServerPermission : IComparable, System.IEquatable[Object]
[System.String[]]
$Permission


ServerPermission ()
{
}

<#
TODO: It was not possible to move this to a parent class. But since these are
generic functions for DatabasePermission and ServerPermission we
Expand Down
4 changes: 4 additions & 0 deletions source/Classes/004.StartupParameters.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ class StartupParameters
[System.UInt32[]]
$InternalTraceFlag

StartupParameters ()
{
}

static [StartupParameters] Parse([System.String] $InstanceStartupParameters)
{
Write-Debug -Message (
Expand Down

0 comments on commit f6ce795

Please sign in to comment.