Skip to content

Commit 573a61a

Browse files
committed
tests: fix tests on Linux
1 parent 977d513 commit 573a61a

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

ScriptLogger/Tests/Unit/Write-ErrorLog.Tests.ps1

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ Describe 'Write-ErrorLog' {
146146

147147
# Assert
148148
$logFile = Get-Content -Path (Join-Path -Path 'TestDrive:' -ChildPath 'test.log')
149-
$logFile | Should -BeLike "2000-12-31 01:02:03 $Env:ComputerName $Env:Username Error ``[Write-ErrorLog.Tests.ps1:$callerLine``] Attempted to divide by zero. (RuntimeException: *\Unit\Write-ErrorLog.Tests.ps1:* char:*)"
149+
$logFile | Should -BeLike "2000-12-31 01:02:03 $Env:ComputerName $Env:Username Error ``[Write-ErrorLog.Tests.ps1:$callerLine``] Attempted to divide by zero. (RuntimeException: *Write-ErrorLog.Tests.ps1:* char:*)"
150150
}
151151

152152
It 'should write a valid message with stack trace to the log' {
@@ -167,8 +167,8 @@ Describe 'Write-ErrorLog' {
167167

168168
# Assert
169169
$logFile = Get-Content -Path (Join-Path -Path 'TestDrive:' -ChildPath 'test.log')
170-
$logFile[0] | Should -BeLike "2000-12-31 01:02:03 $Env:ComputerName $Env:Username Error ``[Write-ErrorLog.Tests.ps1:$callerLine``] Attempted to divide by zero. (RuntimeException: *\Unit\Write-ErrorLog.Tests.ps1:* char:*)"
171-
$logFile[1] | Should -BeLike "at <ScriptBlock>, *\ScriptLogger\Tests\Unit\Write-ErrorLog.Tests.ps1:*"
170+
$logFile[0] | Should -BeLike "2000-12-31 01:02:03 $Env:ComputerName $Env:Username Error ``[Write-ErrorLog.Tests.ps1:$callerLine``] Attempted to divide by zero. (RuntimeException: *Write-ErrorLog.Tests.ps1:* char:*)"
171+
$logFile[1] | Should -BeLike "at <ScriptBlock>, *ScriptLogger*Tests*Unit*Write-ErrorLog.Tests.ps1:*"
172172
}
173173
}
174174

@@ -216,7 +216,7 @@ Describe 'Write-ErrorLog' {
216216
$eventLog.EventID | Should -Be 0
217217
$eventLog.CategoryNumber | Should -Be 0
218218
$eventLog.EntryType | Should -Be 'Error'
219-
$eventLog.Message | Should -BeLike "The description for Event ID '0' in Source 'PowerShell' cannot be found. The local computer may not have the necessary registry information or message DLL files to display the message, or you may not have permission to access them. The following information is part of the event:'``[Write-ErrorLog.Tests.ps1:$callerLine``] Attempted to divide by zero. (RuntimeException: *\Unit\Write-ErrorLog.Tests.ps1:* char:*)'"
219+
$eventLog.Message | Should -BeLike "The description for Event ID '0' in Source 'PowerShell' cannot be found. The local computer may not have the necessary registry information or message DLL files to display the message, or you may not have permission to access them. The following information is part of the event:'``[Write-ErrorLog.Tests.ps1:$callerLine``] Attempted to divide by zero. (RuntimeException: *Write-ErrorLog.Tests.ps1:* char:*)'"
220220
$eventLog.Source | Should -Be 'PowerShell'
221221
$eventLog.InstanceId | Should -Be 0
222222
}
@@ -228,7 +228,7 @@ Describe 'Write-ErrorLog' {
228228

229229
InModuleScope 'ScriptLogger' {
230230

231-
Mock 'Show-ScriptLoggerErrorMessage' -ModuleName 'ScriptLogger' -ParameterFilter { $Message -eq 'My Error' -or $Message -like 'Attempted to divide by zero. (RuntimeException: *\Unit\Write-ErrorLog.Tests.ps1:* char:*)' } -Verifiable
231+
Mock 'Show-ScriptLoggerErrorMessage' -ModuleName 'ScriptLogger' -ParameterFilter { $Message -eq 'My Error' -or $Message -like 'Attempted to divide by zero. (RuntimeException: *Write-ErrorLog.Tests.ps1:* char:*)' } -Verifiable
232232
}
233233
}
234234

0 commit comments

Comments
 (0)