Skip to content

Commit

Permalink
chore: Add patch upgrade test
Browse files Browse the repository at this point in the history
  • Loading branch information
jeromelaban committed Oct 20, 2024
1 parent 5aaef9d commit 7b4c8b4
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/NvGet.Tests/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,12 @@ public static class Constants
};

public static readonly TestPackageFeed TestFeed = new TestPackageFeed(TestFeedUri, TestPackages);

public static readonly Dictionary<string, string[]> TestPackages2 = new Dictionary<string, string[]>
{
{"Uno.UI", new[] { "2.1.39", "2.2.0", "2.2.1", "2.3.0" } },
};

public static readonly TestPackageFeed TestFeed2 = new TestPackageFeed(TestFeedUri, TestPackages2);
}
}
20 changes: 20 additions & 0 deletions src/NvGet.Tests/Tools/Updater/UpdaterParametersTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down

0 comments on commit 7b4c8b4

Please sign in to comment.