fix(appliance): make the Pester Copy-Item mock satisfy the script's copy guard#13
Merged
Conversation
…opy guard Four of the six Hyper-V import tests have failed on every run since they were written - main, v0.5.0 and every dependabot PR since 2026-07-09. Both the test and the guard it trips over landed in the same commit (91f4cc2), so this suite has never been green. The script verifies the VHDX copy actually landed before handing the path to New-VM: Copy-Item -LiteralPath $VhdxPath -Destination $destVhdx -Force if (-not (Test-Path -LiteralPath $destVhdx -PathType Leaf)) { throw "VHDX copy failed..." } That guard is worth keeping - a silently failed copy would otherwise produce a VM pointed at a disk that is not there. The test mocked Copy-Item to a no-op, so the destination never appeared and the guard threw on every test that reached it. The two that passed were the two that fail during validation, before the copy. The mock now creates the destination file, which is what a real copy does. The existing assertion on Copy-Item's Destination parameter still holds. These tests need Windows identity APIs (WindowsIdentity::GetCurrent) and cannot run off Windows, so this is verified by the Scripts workflow rather than locally. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Both jobs in scripts.yml start with `Set-PSRepository PSGallery -InstallationPolicy
Trusted`, which fails hard when PSGallery is not registered yet:
Set-PSRepository: No repository with the name 'PSGallery' was found.
That is an intermittent runner-image state, not a code problem - it flaked this
workflow on a run where the actual test change was correct. Register-if-missing
first, so a runner that has not registered the default gallery does not fail the
job before a single test runs.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Four of the six Hyper-V import tests have failed on every run since they were written —
main,v0.5.0, and every dependabot PR since 2026-07-09. Both the test and the guard it trips over landed in the same commit (91f4cc2), so this suite has never been green.Import-DispatchAppliance.ps1verifies the VHDX copy actually landed before handing the path toNew-VM:That guard is worth keeping — a silently failed copy would otherwise produce a VM pointed at a disk that isn't there. The test mocked
Copy-Itemto a no-op, so the destination never appeared and the guard threw on every test that reached it. The two that "passed" were the two that fail during validation, before the copy — so the suite reported 2/6 while genuinely testing nothing about the creation path.The mock now creates the destination file, which is what a real copy does. The existing assertion on
Copy-Item'sDestinationparameter still holds.Verified on GitHub's Windows runner: Pester reports 6/6 passing.
This is split out from the larger multi-database branch so it isn't gated on that review — it's one file and unrelated to the database work.
🤖 Generated with Claude Code