Add Pester test suite and CI workflow#3
Merged
Conversation
…xy IDs - Set $ErrorActionPreference = 'Stop' inside the try block so unhandled errors in disable/enable/service operations bubble up to the catch instead of silently continuing. - Guard against null dereference in drain loop: check $task.Info and $task.Info.WorkDetails before accessing SourceProxyId. - Guard $runningSessions being null before piping to Get-VBRTaskSession, preventing pipeline errors when no sessions are active. - Replace per-iteration Get-VBRViProxy lookup with a pre-built hashtable ($ProxyIdSet) keyed by proxy ID. Eliminates a redundant VBR API call on every poll cycle, reducing API load during drain waits. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DDj3zuCAvrsZcQKsPpPHvA
Tests cover: - Static analysis: syntax validity, parameter declarations, CmdletBinding - Exit code coverage: all 10 documented exit codes verified present - Robustness checks: ErrorActionPreference, null-safe task info access, session pipeline guard, cached proxy ID lookup - Write-ProxyLog: function existence, parameter signatures, defaults CI workflow runs Pester on ubuntu-latest with pwsh, uploads NUnit XML results as an artifact. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DDj3zuCAvrsZcQKsPpPHvA
Dependency ReviewThe following issues were found:
License Issues.github/workflows/pester.yml
OpenSSF Scorecard
Scanned Files
|
PowerShell's parser interprets `$Node:` as a scope-qualified variable
reference (like `$env:PATH`), causing a parse error: "':' was not
followed by a valid variable name character." Use `${Node}` to
explicitly delimit the variable name from the literal colon.
This bug was caught by the new Pester "parses without syntax errors"
test — the script parsed successfully on Windows PowerShell 5.1 (which
is more lenient) but fails on PowerShell 7 (cross-platform).
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DDj3zuCAvrsZcQKsPpPHvA
PSScriptAnalyzer flagged positional parameter usage on Join-Path. Switch to explicit -Path, -ChildPath, -AdditionalChildPath. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DDj3zuCAvrsZcQKsPpPHvA
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
New test file
tests/sccmpatch.Tests.ps1with 19 Pester tests covering:StageValidateSet,Proxiestype,PollDelay/DrainTimeoutMinutesdefaults), CmdletBinding attribute$ErrorActionPreference = 'Stop', null-safe$task.Info.WorkDetailsaccess,$runningSessionsnull guard, cached$ProxyIdSethashtable usageLevel = 'INFO'New CI workflow
.github/workflows/pester.yml— runs on push/PR tomain, usespwshonubuntu-latest, uploads NUnit XML results as artifact.Branching note
This branch is based on
optimize/script-robustness(PR #1) since the robustness tests validate changes introduced there. Merge PR #1 first, then this one.Test plan
Generated by Claude Code