Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions utils/Integration.TestUtils.psm1
Original file line number Diff line number Diff line change
@@ -1,5 +1,33 @@
# PowerShell module containing utility functions for Sentry console integration tests

function script:Convert-HashtableToObject {
[CmdletBinding()]
param(
[Parameter(Mandatory = $false)]
$Item
)

if ($null -eq $Item) {
return $null
}

if ($Item -is [System.Collections.IDictionary]) {
$obj = [PSCustomObject]@{}
foreach ($key in $Item.Keys) {
if ([string]::IsNullOrWhiteSpace($key)) {
# Skip properties with empty or whitespace-only names
continue
}
$obj | Add-Member -NotePropertyName $key -NotePropertyValue (Convert-HashtableToObject $Item[$key])
}
return $obj
} elseif ($Item -is [System.Collections.IEnumerable] -and -not ($Item -is [string])) {
return @($Item | ForEach-Object { Convert-HashtableToObject $_ })
} else {
return $Item
}
}

function Invoke-CMakeBuild {
[CmdletBinding()]
param(
Expand Down Expand Up @@ -130,6 +158,17 @@ function Get-SentryTestEvent {
}

if ($sentryEvent) {
# Handles Sentry API responses with empty property names as these won't be converted to objects automatically
if ($sentryEvent -is [string]) {
try {
$hashtable = $sentryEvent | ConvertFrom-Json -Depth 50 -AsHashtable
$sentryEvent = Convert-HashtableToObject -Item $hashtable
} catch {
Write-Host "Failed to retrieve Sentry event object: $($_.Exception.Message)" -ForegroundColor Red
return
}
}

Write-Host "Event $($sentryEvent.id) fetched from Sentry" -ForegroundColor Green
$entries = $sentryEvent.entries
$sentryEvent = $sentryEvent | Select-Object -ExcludeProperty 'entries'
Expand Down