Tests for New-WinEvent#4384
Conversation
|
|
||
| Context "New-WinEvent tests" { | ||
|
|
||
| It 'Simple New-WinEvent' -Skip:(-not $IsWindows) { |
There was a problem hiding this comment.
You may want to use $PSDefaultParameterValues to set the value of skip.
There was a problem hiding this comment.
Yup, I saw that approach; but don't really like it; I think having skip conditions explicitly on each test makes it easier to investigate test failures.
There was a problem hiding this comment.
The recommendation according to the testing guidelines is to use PSDefaultParameterValues. Please see: https://github.com/PowerShell/PowerShell/blob/master/docs/testing-guidelines/WritingPesterTests.md
| It 'Simple New-WinEvent' -Skip:(-not $IsWindows) { | ||
| New-WinEvent -ProviderName Microsoft-Windows-PowerShell -Id 40962 -Version 1 # simple event without any payload | ||
| $filter = @{ ProviderName = 'Microsoft-Windows-PowerShell'; Id = 40962} | ||
| (Get-WinEvent -filterHashtable $filter).Count -gt 0 | Should be $true |
There was a problem hiding this comment.
Should be,
(Get-WinEvent -filterHashtable $filter).Count | Should BeGreaterThan 0| } | ||
|
|
||
| It 'No provider found error' -Skip:(-not $IsWindows) { | ||
| { New-WinEvent -ProviderName NonExistingProvider -Id 0 } | ShouldBeErrorID 'System.ArgumentException,Microsoft.PowerShell.Commands.NewWinEventCommand' |
There was a problem hiding this comment.
Typo. Please change "ShouldBeErrorID" -> "ShouldBeErrorId".
|
|
||
| It 'PayloadMismatch error' -Skip:(-not $IsWindows) { | ||
| $logPath = join-path $TestDrive 'testlog1.txt' | ||
| New-WinEvent -ProviderName Microsoft-Windows-PowerShell -Id 32868 *> $logPath # this will print the warning with expected event template to the file |
There was a problem hiding this comment.
Please move the comment on separate line.
| } | ||
|
|
||
| It 'Simple New-WinEvent' { | ||
| New-WinEvent -ProviderName Microsoft-Windows-PowerShell -Id 40962 -Version 1 # simple event without any payload |
There was a problem hiding this comment.
Move the comment to a separate line.
SteveL-MSFT
left a comment
There was a problem hiding this comment.
Which issue does this address if any?
| } | ||
|
|
||
| It 'Simple New-WinEvent' { | ||
| New-WinEvent -ProviderName Microsoft-Windows-PowerShell -Id 40962 -Version 1 # simple event without any payload |
There was a problem hiding this comment.
use something like
$PSProviderId = 40962|
This goes toward #4156 |
|
Based on the code coverage, you're missing some tests:
The Reader code should probably be a different PR |
|
@SteveL-MSFT All of the things that you've mentioned is ETW code and will go into separate PR. |
|
@iSazonov Can you have a look again? |
| } | ||
|
|
||
| It 'Simple New-WinEvent' { | ||
| # simple event without any payload |
There was a problem hiding this comment.
I believe we can remove the comment. And maybe move to the test name.
|
With one minor comment LGTM. |
Some tests for New-WinEvent that bring code coverage of the class to 80%.