From 7b4c8b4b1230f2f484859661b9be8f1abb728c39 Mon Sep 17 00:00:00 2001 From: Jerome Laban Date: Sat, 19 Oct 2024 23:25:27 -0400 Subject: [PATCH] chore: Add patch upgrade test --- src/NvGet.Tests/Constants.cs | 7 +++++++ .../Tools/Updater/UpdaterParametersTests.cs | 20 +++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/src/NvGet.Tests/Constants.cs b/src/NvGet.Tests/Constants.cs index 59dc8ef..04a9156 100644 --- a/src/NvGet.Tests/Constants.cs +++ b/src/NvGet.Tests/Constants.cs @@ -16,5 +16,12 @@ public static class Constants }; public static readonly TestPackageFeed TestFeed = new TestPackageFeed(TestFeedUri, TestPackages); + + public static readonly Dictionary TestPackages2 = new Dictionary + { + {"Uno.UI", new[] { "2.1.39", "2.2.0", "2.2.1", "2.3.0" } }, + }; + + public static readonly TestPackageFeed TestFeed2 = new TestPackageFeed(TestFeedUri, TestPackages2); } } diff --git a/src/NvGet.Tests/Tools/Updater/UpdaterParametersTests.cs b/src/NvGet.Tests/Tools/Updater/UpdaterParametersTests.cs index be77165..ad0bb10 100644 --- a/src/NvGet.Tests/Tools/Updater/UpdaterParametersTests.cs +++ b/src/NvGet.Tests/Tools/Updater/UpdaterParametersTests.cs @@ -111,6 +111,26 @@ public async Task GivenRangeOverrides_KeepMinor() Assert.AreEqual(NuGetVersion.Parse("2.3.0-dev.44"), version.Version); } + [TestMethod] + public async Task GivenRangeOverrides_KeepPatch() + { + var reference = new PackageReference("Uno.UI", "2.2.0"); + + var parameters = new UpdaterParameters + { + TargetVersions = { "dev", "stable" }, + Feeds = { Constants.TestFeed2 }, + VersionOverrides = + { + { reference.Identity.Id, (false, UpgradePolicy.Patch, VersionRange.Parse("0.0.0.0")) }, + }, + }; + + var version = await parameters.GetLatestVersion(CancellationToken.None, reference); + + Assert.AreEqual(NuGetVersion.Parse("2.2.1"), version.Version); + } + [TestMethod] public async Task GivenRangeOverrides_CorrectVersionsAreResolved_AndTargetVersionIsHonored() {