-
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathadd-sentry-event-processor.tests.ps1
More file actions
49 lines (40 loc) · 1.4 KB
/
add-sentry-event-processor.tests.ps1
File metadata and controls
49 lines (40 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
BeforeAll {
. "$PSScriptRoot/utils.ps1"
}
Describe 'Add-SentryEventProcessor' {
BeforeEach {
$events = [System.Collections.Generic.List[Sentry.SentryEvent]]::new();
$transport = [RecordingTransport]::new()
StartSentryForEventTests ([ref] $events) ([ref] $transport)
}
AfterEach {
$events.Clear()
Stop-Sentry
}
It 'Mutates events via $_' {
Add-SentryEventProcessor { $_.SetTag('custom', 'value'); $_ }
'msg' | Out-Sentry
$events[0].Tags['custom'] | Should -Be 'value'
}
It 'Drops events when the script block returns $null' {
Add-SentryEventProcessor {
if ($_.Message.Message -match 'drop-me') { return $null }
$_
}
'drop-me please' | Out-Sentry
'keep this one' | Out-Sentry
$events.Count | Should -Be 1
$events[0].Message.Message | Should -Be 'keep this one'
}
It 'Chains multiple processors in registration order' {
Add-SentryEventProcessor { $_.SetTag('first', '1'); $_ }
Add-SentryEventProcessor { $_.SetTag('second', '2'); $_ }
'msg' | Out-Sentry
$events[0].Tags['first'] | Should -Be '1'
$events[0].Tags['second'] | Should -Be '2'
}
It 'Throws when Sentry is not initialized' {
Stop-Sentry
{ Add-SentryEventProcessor { $_ } } | Should -Throw '*Sentry is not initialized*'
}
}