Skip to content

Commit 045d74e

Browse files
authored
test: integration test improvement (#64)
* update tests * remove empty lines
1 parent 7f6803d commit 045d74e

File tree

2 files changed

+33
-112
lines changed

2 files changed

+33
-112
lines changed

tests/integration-test-script.ps1

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,32 @@ $PSNativeCommandUseErrorActionPreference = $true
44

55
Import-Module ../modules/Sentry/Sentry.psd1
66
. ./utils.ps1
7+
. ./throwingshort.ps1
78

89
$events = [System.Collections.Generic.List[Sentry.SentryEvent]]::new();
910
$transport = [RecordingTransport]::new()
1011
StartSentryForEventTests ([ref] $events) ([ref] $transport)
1112

1213
try
1314
{
14-
funcA 'throw' 'error'
15+
funcC
1516
}
1617
catch
1718
{
1819
$_ | Out-Sentry | Out-Null
1920
}
2021

21-
$events[0].SentryThreads.Stacktrace.Frames | ForEach-Object {
22+
$thread = $events[0].SentryThreads | Where-Object { $_.Id -eq 0 }
23+
$thread.Stacktrace.Frames | ForEach-Object {
2224
'----------------' | Out-String
2325
$frame = $_
2426
$properties = $frame | Get-Member -MemberType Properties | Select-Object -ExpandProperty Name
2527
foreach ($prop in $properties)
2628
{
2729
$value = $frame.$prop | Out-String -Width 500
28-
"$($prop): $value"
30+
if ("$value" -ne '')
31+
{
32+
"$($prop): $value"
33+
}
2934
}
3035
}

tests/integration.tests.ps1

Lines changed: 25 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
BeforeAll {
22
$integrationTestScript = "$PSScriptRoot$([IO.Path]::DirectorySeparatorChar)integration-test-script.ps1"
3+
$integrationTestThrowingScript = "$PSScriptRoot$([IO.Path]::DirectorySeparatorChar)throwingshort.ps1"
34
$integrationTestScriptContent = Get-Content -Raw $integrationTestScript
45

56
$checkOutput = {
@@ -43,64 +44,23 @@ Describe 'Out-Sentry captures expected stack traces for command argument' -Skip:
4344
$expected = @(
4445
'----------------'
4546
'AbsolutePath: <No file>'
46-
'AddressMode: '
47-
'ColumnNumber: '
48-
'ContextLine: '
49-
'FileName: '
50-
'FramesOmitted: '
5147
'Function: <ScriptBlock>'
52-
'FunctionId: '
53-
'ImageAddress: '
5448
'InApp: True'
55-
'InstructionAddress: '
5649
'LineNumber: 1'
57-
'Module: '
58-
'Package: '
59-
'Platform: '
60-
'PostContext: '
61-
'PreContext: '
62-
'SymbolAddress: '
63-
'Vars: '
6450
'----------------'
6551
'AbsolutePath: <No file>'
66-
'AddressMode: '
67-
'ColumnNumber: '
68-
'ContextLine: '
69-
'FileName: '
70-
'FramesOmitted: '
7152
'Function: <ScriptBlock>'
72-
'FunctionId: '
73-
'ImageAddress: '
7453
'InApp: True'
75-
'InstructionAddress: '
76-
'LineNumber: 14'
77-
'Module: '
78-
'Package: '
79-
'Platform: '
80-
'PostContext: '
81-
'PreContext: '
82-
'SymbolAddress: '
83-
'Vars: '
54+
'LineNumber: 15'
8455
'----------------'
85-
'AbsolutePath: '
86-
'AddressMode: '
56+
"AbsolutePath: $integrationTestThrowingScript"
8757
'ColumnNumber: 5'
88-
"ContextLine: funcA 'throw' 'error'"
89-
'FileName: '
90-
'FramesOmitted: '
91-
'Function: '
92-
'FunctionId: '
93-
'ImageAddress: '
58+
'ContextLine: throw "Short context test"'
59+
'Function: funcC'
9460
'InApp: True'
95-
'InstructionAddress: '
96-
'LineNumber: 14'
97-
'Module: '
98-
'Package: '
99-
'Platform: '
100-
'PostContext: '
101-
'PreContext: '
102-
'SymbolAddress: '
103-
'Vars: '
61+
'LineNumber: 2'
62+
'PostContext: }'
63+
'PreContext: function funcC {'
10464
)
10565

10666
}
@@ -126,44 +86,18 @@ Describe 'Out-Sentry captures expected stack traces for piped command' {
12686
$expected = @(
12787
'----------------'
12888
'AbsolutePath: <No file>'
129-
'AddressMode: '
130-
'ColumnNumber: '
131-
'ContextLine: '
132-
'FileName: '
133-
'FramesOmitted: '
13489
'Function: <ScriptBlock>'
135-
'FunctionId: '
136-
'ImageAddress: '
13790
'InApp: True'
138-
'InstructionAddress: '
13991
'LineNumber: 3'
140-
'Module: '
141-
'Package: '
142-
'Platform: '
143-
'PostContext: '
144-
'PreContext: '
145-
'SymbolAddress: '
146-
'Vars: '
14792
'----------------'
148-
'AbsolutePath: '
149-
'AddressMode: '
93+
"AbsolutePath: $integrationTestThrowingScript"
15094
'ColumnNumber: 5'
151-
"ContextLine: funcA 'throw' 'error'"
152-
'FileName: '
153-
'FramesOmitted: '
154-
'Function: '
155-
'FunctionId: '
156-
'ImageAddress: '
95+
'ContextLine: throw "Short context test"'
96+
'Function: funcC'
15797
'InApp: True'
158-
'InstructionAddress: '
159-
'LineNumber: 3'
160-
'Module: '
161-
'Package: '
162-
'Platform: '
163-
'PostContext: '
164-
'PreContext: '
165-
'SymbolAddress: '
166-
'Vars: '
98+
'LineNumber: 2'
99+
'PostContext: }'
100+
'PreContext: function funcC {'
167101
)
168102
}
169103

@@ -188,40 +122,15 @@ Describe 'Out-Sentry captures expected stack traces for file input' {
188122
$expected = @(
189123
'----------------'
190124
'AbsolutePath: <No file>'
191-
'AddressMode: '
192-
'ColumnNumber: '
193-
'ContextLine: '
194-
'FileName: '
195-
'FramesOmitted: '
196125
'Function: <ScriptBlock>'
197-
'FunctionId: '
198-
'ImageAddress: '
199126
'InApp: True'
200-
'InstructionAddress: '
201127
'LineNumber: 1'
202-
'Module: '
203-
'Package: '
204-
'Platform: '
205-
'PostContext: '
206-
'PreContext: '
207-
'SymbolAddress: '
208-
'Vars: '
209128
'----------------'
210129
"AbsolutePath: $integrationTestScript"
211-
'AddressMode: '
212-
'ColumnNumber: 5'
213-
"ContextLine: funcA 'throw' 'error'"
214-
'FileName: '
215-
'FramesOmitted: '
130+
'ContextLine: funcC'
216131
'Function: <ScriptBlock>'
217-
'FunctionId: '
218-
'ImageAddress: '
219132
'InApp: True'
220-
'InstructionAddress: '
221-
'LineNumber: 14'
222-
'Module: '
223-
'Package: '
224-
'Platform: '
133+
'LineNumber: 15'
225134
'PostContext: }'
226135
'catch'
227136
'{'
@@ -231,8 +140,15 @@ Describe 'Out-Sentry captures expected stack traces for file input' {
231140
'StartSentryForEventTests ([ref] $events) ([ref] $transport)'
232141
'try'
233142
'{'
234-
'SymbolAddress: '
235-
'Vars: '
143+
'----------------'
144+
"AbsolutePath: $integrationTestThrowingScript"
145+
'ColumnNumber: 5'
146+
'ContextLine: throw "Short context test"'
147+
'Function: funcC'
148+
'InApp: True'
149+
'LineNumber: 2'
150+
'PostContext: }'
151+
'PreContext: function funcC {'
236152
)
237153
}
238154

0 commit comments

Comments
 (0)