33 lines
2.0 KiB
PowerShell
33 lines
2.0 KiB
PowerShell
Describe 'CLI error reporting' {
|
|
It 'prints a concise error and preserves exit code 2' {
|
|
$output = & (Join-Path $PSHOME $(if ($IsWindows) { 'pwsh.exe' } else { 'pwsh' })) -NoProfile -File "$PSScriptRoot/../cc.ps1" plan -Machine missing-test-machine -DataRoot "$TestDrive/data" 2>&1
|
|
$LASTEXITCODE | Should -Be 2
|
|
($output | Out-String) | Should -Match 'Config Central could not complete:'
|
|
($output | Out-String) | Should -Not -Match 'Write-Error:|CategoryInfo|FullyQualifiedErrorId'
|
|
}
|
|
|
|
It 'keeps structured errors available to automation' {
|
|
$output = & (Join-Path $PSHOME $(if ($IsWindows) { 'pwsh.exe' } else { 'pwsh' })) -NoProfile -File "$PSScriptRoot/../cc.ps1" plan -Machine missing-test-machine -DataRoot "$TestDrive/data" -Json
|
|
$LASTEXITCODE | Should -Be 2
|
|
$result = $output | ConvertFrom-Json
|
|
$result.succeeded | Should -BeFalse
|
|
$result.exitCode | Should -Be 2
|
|
$result.error | Should -Not -BeNullOrEmpty
|
|
}
|
|
}
|
|
|
|
Describe 'Software update CLI' {
|
|
It 'recognizes update-software as a command' {
|
|
$output = & (Join-Path $PSHOME $(if ($IsWindows) { 'pwsh.exe' } else { 'pwsh' })) -NoProfile -File "$PSScriptRoot/../cc.ps1" update-software -Machine missing-test-machine -DataRoot "$TestDrive/software-data" 2>&1
|
|
$LASTEXITCODE | Should -Be 2
|
|
($output | Out-String) | Should -Match 'No repository branch is configured'
|
|
($output | Out-String) | Should -Not -Match 'ValidateSet|Cannot validate argument'
|
|
}
|
|
It 'accepts software-update as an alias for the canonical command' {
|
|
$output = & (Join-Path $PSHOME $(if ($IsWindows) { 'pwsh.exe' } else { 'pwsh' })) -NoProfile -File "$PSScriptRoot/../cc.ps1" software-update -Machine missing-test-machine -DataRoot "$TestDrive/software-alias-data" 2>&1
|
|
$LASTEXITCODE | Should -Be 2
|
|
($output | Out-String) | Should -Match 'No repository branch is configured'
|
|
($output | Out-String) | Should -Not -Match 'ValidateSet|Cannot validate argument'
|
|
}
|
|
}
|