Skip to content

Commit

Permalink
SqlAudit: Fix unit tests (#2038)
Browse files Browse the repository at this point in the history
- SqlAudit
  - Fixed unit tests.
  • Loading branch information
johlju authored Jul 19, 2024
1 parent fa20deb commit 00c2341
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `Connect-SqlDscDatabaseEngine`
- Comment-based help for parameter `LoginType` was corrected.
- An integration test now runs to test the command.
- SqlAudit
- Fixed unit tests.
- SqlDatabaseMail
- Fix unit test, removing `Assert-VerifiableMock` that was left over from
Pester 5 conversion.

## [16.6.0] - 2024-05-17

Expand Down
18 changes: 12 additions & 6 deletions tests/Unit/Classes/SqlAudit.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ Describe 'SqlAudit\Set()' -Tag 'Set' {
}
}

It 'Should not call method Modify()' {
It 'Should call method Modify()' {
InModuleScope -ScriptBlock {
$script:mockSqlAuditInstance.Set()

Expand Down Expand Up @@ -346,11 +346,17 @@ Describe 'SqlAudit\Test()' -Tag 'Test' {
$script:mockSqlAuditInstance |
# Mock method Compare() which is called by the base method Set()
Add-Member -Force -MemberType 'ScriptMethod' -Name 'Compare' -Value {
return @{
Name = 'MockAuditName'
InstanceName = 'NamedInstance'
Path = 'C:\WrongFolder'
}
<#
Compare() method shall only return the properties NOT in
desired state, in the format of the command Compare-DscParameterState.
#>
return @(
@{
Property = 'Path'
ExpectedValue = 'C:\Temp'
ActualValue = 'C:\WrongFolder'
}
)
} -PassThru |
Add-Member -Force -MemberType 'ScriptMethod' -Name 'AssertProperties' -Value {
return
Expand Down
2 changes: 0 additions & 2 deletions tests/Unit/DSC_SqlDatabaseMail.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -1141,6 +1141,4 @@ Describe 'DSC_SqlDatabaseMail\Set-TargetResource' -Tag 'Set' {
}
}
}

Assert-VerifiableMock
}

0 comments on commit 00c2341

Please sign in to comment.