22 lines
1.8 KiB
PowerShell
22 lines
1.8 KiB
PowerShell
$ErrorActionPreference='Stop'
|
|||
|
|
. (Join-Path $PSScriptRoot "../scripts/workflow-run-status.ps1")
|
||
|
|
$root=Join-Path ([IO.Path]::GetTempPath()) ('workflow-status-'+[guid]::NewGuid().ToString('N'))
|
||
|
|
[void][IO.Directory]::CreateDirectory((Join-Path $root 'receipts'))
|
||
|
|
[void][IO.Directory]::CreateDirectory((Join-Path $root 'outputs'))
|
||
|
|
$now=Get-Date
|
||
|
|
$logDir=Join-Path $root ('logs/{0}/{1:D2}/{2:D2}' -f $now.Year,$now.Month,$now.Day)
|
||
|
|
[void][IO.Directory]::CreateDirectory($logDir)
|
||
|
|
$report=Join-Path $root 'outputs\report.md'
|
||
|
|
Set-Content -LiteralPath $report -Value '# Verified fixture report'
|
||
|
|
$receiptPath=Join-Path $root 'receipts\run.json'
|
||
|
|
$r=@{skill=@{name='workflow-demo'}; finished_at=(Get-Date).AddMinutes(-5).ToString('o');status='success';validation=@{deterministic='pass';manual='pass'};artifacts=@{report='outputs/report.md';checkpoint_advanced=$true};failures=@()}
|
||
|
|
function Save-Fixture { $r | ConvertTo-Json -Depth 5 | Set-Content -LiteralPath $receiptPath }
|
||
|
|
function Check-Outcome($expected) { $actual=Get-WorkflowRunStatus -WorkflowId workflow-demo -Repository $root -LogRoot (Join-Path $root 'logs'); if($actual.outcome -ne $expected){throw "Expected $expected, got $($actual.outcome)"} }
|
||
|
|
Save-Fixture; Check-Outcome 'success'
|
||
|
|
$r.status='failed'; $r.failures=@('Search unavailable'); Save-Fixture; Check-Outcome 'failure'
|
||
|
|
$r.status='success'; $r.failures=@(); $r.validation.manual='fail'; Save-Fixture; Check-Outcome 'unknown'
|
||
|
|
$r.validation.manual='pass'; Save-Fixture
|
||
|
|
Set-Content -LiteralPath (Join-Path $logDir 'test.log') -Value ((Get-Date).AddMinutes(-2).ToUniversalTime().ToString('o')+' warning [automations] Scheduled run failed automationId=workflow-demo errorMessage="Backend timeout"')
|
||
|
|
Check-Outcome 'failure'
|
||
|
|
$r.finished_at=(Get-Date).ToString('o'); Save-Fixture; Check-Outcome 'success'
|
||
|
|
Write-Output 'Passed five receipt/scheduler status cases.'
|