Skip to content

Migrate Package Source Mapping tests#7308

Draft
nkolev92 wants to merge 8 commits intodevfrom
dev-nkolev92-migratePSMTests
Draft

Migrate Package Source Mapping tests#7308
nkolev92 wants to merge 8 commits intodevfrom
dev-nkolev92-migratePSMTests

Conversation

@nkolev92
Copy link
Copy Markdown
Member

@nkolev92 nkolev92 commented Apr 20, 2026

Bug

Fixes: NuGet/Home#12185

Description

Migrates PowerShell E2E tests from PackageNameSpaceTests.ps1 to C# Apex tests. The feature was renamed from "PackageNameSpace" to "PackageSourceMapping", so new test names reflect the current terminology.

Migration decisions

# PS Test Function Decision Apex Target Notes
1 Test-PackageSourceMappingRestore-WithSingleFeed Deferred [SkipTest]. Restore-on-build test: manually writes packages.config, builds via Build-Solution. Can be migrated using SolutionService.Build() in a follow-up.
2 Test-PackageSourceMappingRestore-WithMultipleFeedsWithIdenticalPackages-RestoresCorrectPackage Deferred [SkipTest]. Same restore-on-build pattern as #1 with two feeds and content-file verification. Can be migrated using SolutionService.Build() in a follow-up.
3 Test-VsPackageInstallerServices-PackageSourceMappingInstall-WithSingleFeed-Succeed Delete (already covered) IVsServicesTestCase.SimpleInstallFromIVsInstaller_PackageSourceMapping_WithSingleFeed Existing Apex test covers the same scenario.
4 Test-VsPackageInstallerServices-PackageSourceMappingInstall-WithSingleFeed-Fails Migrate IVsServicesTestCase.SimpleInstallFromIVsInstaller_PackageSourceMapping_WithMissingMappedSource_Fails Error-path: maps pattern to non-existent source, asserts package NOT installed.
5 Test-VsPackageInstallerServices-PackageSourceMappingInstall-WithMultipleFeedsWithIdenticalPackages-RestoresCorrectPackageWithSpecifiedVersion Delete (already covered) IVsServicesTestCase.SimpleInstallFromIVsInstaller_PackageSourceMapping_WithMultipleFeedsWithIdenticalPackages_InstallsCorrectPackage Existing Apex test covers specified-version install with content file verification.
6 Test-VsPackageInstallerServices-PackageSourceMappingInstall-WithMultipleFeedsWithIdenticalPackages-RestoresCorrectPackageWithLatestVersion Migrate IVsServicesTestCase.SimpleInstallLatestFromIVsInstaller_PackageSourceMapping_WithMultipleFeedsWithIdenticalPackages_InstallsCorrectPackage Latest-version (no version specified) install from mapped source, verifying correct feed via content file.
7 Test-PC-PackageSourceMappingInstall-Succeed Delete (already covered) NuGetConsoleTestCase.InstallPackageForPC_PackageSourceMapping_WithSingleFeed Existing Apex test covers single-feed PMC install.
8 Test-PC-PackageSourceMappingInstall-Fails Migrate NuGetConsoleTestCase.InstallPackageForPC_PackageSourceMapping_WithWrongMappedFeed_Fails Error-path: two feeds, pattern mapped to wrong feed, asserts PMC error message.
9 Test-PC-PackageSourceMappingInstall-WithCorrectSourceOption-Succeed Migrate NuGetConsoleTestCase.InstallPackageForPC_PackageSourceMapping_WithCorrectSourceOption_InstallsCorrectPackage Uses -Source to install from mapped private feed, verifies content file origin.
10 Test-PC-PackageSourceMappingInstall-WithWrongSourceOption-Fails Migrate NuGetConsoleTestCase.InstallPackageForPC_PackageSourceMapping_WithWrongSourceOption_Fails Error-path: -Source points to unmapped feed, asserts PMC error message.
11 Test-PC-PackageSourceMappingUpdate-WithCorrectSourceOption-Succeed Migrate NuGetConsoleTestCase.UpdatePackageForPC_PackageSourceMapping_WithCorrectSourceOption_UpdatesCorrectPackage Install v1 then update to v2 from mapped source, verifies content file origin.
CreateCustomTestPackage (helper) Keep in PS Still used by tests #1 and #2.

File changes

  • NuGetConsoleTestCase.cs — 4 new PMC tests (tests 8, 9, 10, 11)
  • IVsServicesTestCase.cs — 2 new IVs API tests (tests 4, 6)
  • PackageNameSpaceTests.ps1 — Deleted 9 functions (tests 3-11), kept tests 1-2 and helper
  • SKILL.md — Updated Apex migration skill with learnings

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.

nkolev92 and others added 2 commits April 20, 2026 14:33
Replaced CreateConfigurationFile with Settings.AddSource() and
Settings.AddPackageSourceMapping() in 4 PMC source mapping tests to
preserve SimpleTestPathContext defaults (globalPackagesFolder, etc.).
Also reuse the default 'source' feed as the opensource repo where possible.

Updated apex-migration skill with config gotcha learning.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Comment thread test/NuGet.Tests.Apex/NuGet.Tests.Apex/NuGetEndToEndTests/NuGetConsoleTestCase.cs Outdated
Comment thread test/NuGet.Tests.Apex/NuGet.Tests.Apex/NuGetEndToEndTests/NuGetConsoleTestCase.cs Outdated
nkolev92 and others added 3 commits April 22, 2026 19:08
…pleTestPathContext

- Migrate 2 PS PackageNameSpaceTests (restore with source mapping) to Apex
- Fix 6 NuGetConsoleTestCase tests to use SimpleTestPathContext APIs instead of CreateConfigurationFile
- Remove migrated PS functions and CreateCustomTestPackage helper

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants