test: pin requested-version import for PSGalleryModule and PSResourceGet#191
Merged
Conversation
…Get (#44, #55) Adds regression tests for two fixed behaviours: - PSGalleryModule (#44): when multiple versions are installed and an older one is explicitly requested, Import-PSDependModule receives that exact version (not the maximum). Mirrors the equivalent assertion already present in PSResourceGet.Type.Tests.ps1. - PSResourceGet (#44): extends the existing 'Multiple installed versions' context with an import-version assertion (Test,Import action) to lock in the same guarantee for the PSResourceGet handler. - PSGalleryModule (#55): Repository = $null skips Get-PSRepository and calls Install-Module without a -Repository argument, allowing PowerShellGet to search all registered repositories. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Adds/extends Pester coverage to ensure PSDepend imports the explicitly requested module version when multiple versions are installed, and that a $null repository value falls back to all registered repositories (no -Repository passed to Install-Module). This aligns with expected behavior for PSGalleryModule and PSResourceGet dependency types and guards against regressions for issues #44 and #55.
Changes:
- Add PSGalleryModule test case asserting the requested version (not max installed) is passed to
Import-PSDependModuleand install is skipped. - Add PSResourceGet test case asserting requested version is used on
Test, Importwhen multiple installed versions exist. - Add PSGalleryModule test case asserting
$nullrepository skips validation and callsInstall-Modulewithout-Repository.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| Tests/PSGalleryModule.Type.Tests.ps1 | Adds contexts covering requested-version import selection and $null repository fall-through behavior. |
| Tests/PSResourceGet.Type.Tests.ps1 | Adds an Import assertion ensuring the requested version is imported when multiple versions are installed. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| & $ScriptPath -Dependency $Dep -PSDependAction Test, Import | ||
| } | ||
| Should -Invoke -CommandName Import-PSDependModule -ModuleName PSDepend -Times 1 -Exactly ` | ||
| -ParameterFilter { $Version.ToString() -eq '1.2.3' } |
| & $ScriptPath -Dependency $Dep -PSDependAction Test, Import | ||
| } | ||
| Should -Invoke -CommandName Import-PSDependModule -ModuleName PSDepend -Times 1 -Exactly ` | ||
| -ParameterFilter { $Version.ToString() -eq '1.2.3' } |
Test Results 3 files 66 suites 1m 13s ⏱️ Results for commit 7e4eb3a. |
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
Import-PSDependModulereceives the explicitly requested version (1.2.3), not the maximum installed (2.0.0), andInstall-Moduleis not called.Itthat invokes withTest, Importand assertsImport-PSDependModulereceives version 1.2.3.Get-PSRepositoryis skipped andInstall-Moduleis called without a-Repositoryargument whenRepositoryis null.Closes #44, #55. Will also close #48, #69, #94 after merge (no new code needed for those; see individual issue comments).
Test plan
.\build.ps1 StageFiles; Invoke-Pester Tests/PSGalleryModule.Type.Tests.ps1, Tests/PSResourceGet.Type.Tests.ps1— 29 tests, 0 failures🤖 Generated with Claude Code