Skip to content
Open
1 change: 1 addition & 0 deletions scripts/linting/Invoke-PSScriptAnalyzer.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ function Invoke-PSScriptAnalyzerCore {
Warnings = @($allResults | Where-Object Severity -eq 'Warning').Count
Information = @($allResults | Where-Object Severity -eq 'Information').Count
HasErrors = $hasErrors
Timestamp = Get-StandardTimestamp
}

# Ensure logs directory exists
Expand Down
11 changes: 11 additions & 0 deletions scripts/tests/linting/Invoke-PSScriptAnalyzer.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,17 @@ Describe 'Output Generation' -Tag 'Unit' {
try { Invoke-PSScriptAnalyzerCore -OutputPath $script:OutputFile } catch { $null = $_ }
{ Get-Content $script:OutputFile | ConvertFrom-Json } | Should -Not -Throw
}

It 'Summary file contains a valid UTC timestamp' {
try { Invoke-PSScriptAnalyzerCore -OutputPath $script:OutputFile } catch { $null = $_ }

$summaryFile = Join-Path (Split-Path $script:OutputFile -Parent) 'psscriptanalyzer-summary.json'
$summaryRaw = Get-Content $summaryFile -Raw
$summary = $summaryRaw | ConvertFrom-Json

$summary.Timestamp | Should -Not -BeNullOrEmpty
$summaryRaw | Should -Match '"Timestamp"\s*:\s*"[^"]+Z"'
}
}
}

Expand Down
Loading