Skip to content

Migrate Find-Package and Get-Package E2E tests to unit tests#7526

Merged
nkolev92 merged 6 commits into
devfrom
dev-nkolev92-cleanup
Jul 16, 2026
Merged

Migrate Find-Package and Get-Package E2E tests to unit tests#7526
nkolev92 merged 6 commits into
devfrom
dev-nkolev92-cleanup

Conversation

@nkolev92

@nkolev92 nkolev92 commented Jun 29, 2026

Copy link
Copy Markdown
Member

Bug

Progress: https://github.com/NuGet/Client.Engineering/issues/2085
Fixes: NuGet/Home#8496

Description

Continues the migration of legacy PowerShell end-to-end tests (test/EndToEnd/tests/*.ps1) to fast, in-process unit tests, following the repo's apex-migration playbook.

This PR migrates the last remaining functions in FindPackageTest.ps1 and GetPackageTest.ps1. Both files are deleted and removed from NuGet.sln. Every scenario describes pure Find-Package / Get-Package cmdlet behavior (paging, version collapsing, source-name resolution), so all were migrated as unit tests in NuGetConsole.Host.PowerShell.Test rather than Apex tests — no VS integration is required to exercise them. VS-level source resolution is already covered by the existing GetPackage_InstallListAndUpdateLifecycleAsync Apex test.

Test migration mapping

Old PS function (file) New test(s) Notes
Test-FindPackageByIdWithFirstAndSkip (FindPackageTest.ps1) FindPackage_WithFirst_LimitsNumberOfResultsAsync, FindPackage_WithSkipBeyondResultCount_ReturnsEmptyAsync, FindPackage_WithFirstAndSkip_ReturnsLimitedResultsAsync -First/-Skip paging split into focused cases
Test-GetPackageCollapsesPackageVersionsForListAvailable (GetPackageTest.ps1) GetPackageListAvailable_CollapsesMultipleVersionsToSingleEntryAsync Multiple versions collapse to one entry
Test-GetPackageRetunsMoreThanServerPagingLimit (GetPackageTest.ps1) GetPackageListAvailable_WithLargeFirst_ReturnsMoreThanServerPagingLimitAsync Needs explicit large -First; -ListAvailable defaults First=50
Test-GetPackageAcceptsSourceName (GetPackageTest.ps1) GetPackageListAvailable_WithSourceByName_ReturnsPackagesAsync -Source <name> resolved via mocked package source provider
Test-GetPackageWithUpdatesAcceptsSourceName (GetPackageTest.ps1) GetPackageUpdates_WithSourceByName_ReturnsUpdatesAsync -Updates -Source <name> returns updates
Test-GetPackageUpdatesAfterSwitchToSourceThatDoesNotContainInstalledPackageId (GetPackageTest.ps1) GetPackageUpdates_FromSourceWithoutInstalledPackage_ReturnsEmptyAsync -Updates against a source lacking the installed id returns 0
GetPackageAcceptsAllAsSourceName (GetPackageTest.ps1) Dropped -Source 'All' is a host-level (PMC dropdown) concept handled by PowerShellHost, not a cmdlet -Source value — passing it literally throws "Unknown source 'All'". The function also lacked a Test- prefix, so it never ran.

Files changed

  • Added 3 unit tests to FindPackageCommandTests.cs and 5 to GetPackageCommandTests.cs (plus a SetupSourceRepositoryProvider(IEnumerable<PackageSource>) overload for source-name scenarios).
  • Deleted FindPackageTest.ps1 and GetPackageTest.ps1; removed their NuGet.sln solution items.
  • Updated the apex-migration skill with learnings from this migration.

This branch also carries earlier cleanup commits (dead-code removal in LocalPackageSearchResource + tests, VSSolutionManager, ProjectSystemCacheTests, package version housekeeping).

PR Checklist

  • Meaningful title, helpful description and a linked NuGet/Home issue
  • Added tests
  • Link to an issue or pull request to update docs if this PR changes settings, environment variables, new feature, etc.

@dotnet-policy-service dotnet-policy-service Bot added the Status:No recent activity PRs that have not had any recent activity and will be closed if the label is not removed label Jul 6, 2026
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

This PR has been automatically marked as stale because it has no activity for 7 days. It will be closed if no further activity occurs within another 7 days of this comment. If it is closed, you may reopen it anytime when you're ready again, as long as you don't delete the branch.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR continues the migration of legacy PowerShell end-to-end tests for Find-Package and Get-Package into faster in-process unit tests under NuGetConsole.Host.PowerShell.Test, deleting the old .ps1 test files and updating related migration guidance.

Changes:

  • Added unit tests covering paging (-First/-Skip), version collapsing, and -Source-by-name behavior for Find-Package / Get-Package.
  • Deleted the legacy E2E test scripts FindPackageTest.ps1 and GetPackageTest.ps1 and removed them from NuGet.sln solution items.
  • Updated the apex-migration skill documentation; also re-enabled one previously skipped E2E test in InstallPackageTest.ps1.
Show a summary per file
File Description
test/NuGet.Clients.Tests/NuGetConsole.Host.PowerShell.Test/Cmdlets/GetPackageCommandTests.cs Adds unit tests for Get-Package behaviors (collapse versions, paging beyond 100, source-name resolution, updates filtering) and a helper overload for named sources.
test/NuGet.Clients.Tests/NuGetConsole.Host.PowerShell.Test/Cmdlets/FindPackageCommandTests.cs Adds unit tests for Find-Package paging behavior with -First and -Skip.
test/EndToEnd/tests/InstallPackageTest.ps1 Removes a SkipTest attribute, re-enabling Test-InstallPackageWithValuesFromPipe.
test/EndToEnd/tests/GetPackageTest.ps1 Deletes legacy E2E tests now covered by unit tests.
test/EndToEnd/tests/FindPackageTest.ps1 Deletes legacy E2E tests now covered by unit tests.
NuGet.sln Removes deleted E2E scripts from solution items.
.copilot/skills/apex-migration/SKILL.md Documents learnings and guidance from this paging/source-name migration.

Review details

  • Files reviewed: 7/7 changed files
  • Comments generated: 1
  • Review effort level: Low

Comment thread test/EndToEnd/tests/InstallPackageTest.ps1
@dotnet-policy-service dotnet-policy-service Bot removed the Status:No recent activity PRs that have not had any recent activity and will be closed if the label is not removed label Jul 6, 2026
@nkolev92
nkolev92 marked this pull request as ready for review July 6, 2026 20:13
@nkolev92
nkolev92 requested a review from a team as a code owner July 6, 2026 20:13
@nkolev92
nkolev92 requested review from donnie-msft and martinrrm July 6, 2026 20:13
@nkolev92
nkolev92 requested a review from jebriede July 9, 2026 20:32
@nkolev92
nkolev92 enabled auto-merge (squash) July 13, 2026 16:42
martinrrm
martinrrm previously approved these changes Jul 13, 2026
jebriede
jebriede previously approved these changes Jul 14, 2026

@jebriede jebriede left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approve with test suggestion

@nkolev92
nkolev92 dismissed stale reviews from jebriede and martinrrm via 8c5b4fe July 15, 2026 01:15
@nkolev92
nkolev92 requested review from jebriede and martinrrm July 15, 2026 01:16
@nkolev92
nkolev92 force-pushed the dev-nkolev92-cleanup branch from 8c5b4fe to 6bfe835 Compare July 15, 2026 01:16
nkolev92 and others added 6 commits July 15, 2026 09:37
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Use exact, ordered sequence assertions in FindPackageCommandTests instead of
count-based/Contain checks, relying on the deterministic ordering of the local
package source (ids ascending, versions descending). The paging test now
verifies the skip offset window, not just the result count.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@nkolev92
nkolev92 force-pushed the dev-nkolev92-cleanup branch from 6bfe835 to cdb3300 Compare July 15, 2026 16:37
@nkolev92
nkolev92 merged commit 9ef3ab3 into dev Jul 16, 2026
20 of 21 checks passed
@nkolev92
nkolev92 deleted the dev-nkolev92-cleanup branch July 16, 2026 18:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Test: 3 search-related tests failing consistently

4 participants