From 6bbd2b72c16454d3ee14850e0d79a17297b1ecab Mon Sep 17 00:00:00 2001 From: Daniel Plaisted Date: Wed, 27 Mar 2024 07:32:19 -0400 Subject: [PATCH] Add test for updating workloads in workload set mode with no workload sets available --- .../WorkloadSetTests.cs | 52 ++++++++++++++----- 1 file changed, 38 insertions(+), 14 deletions(-) diff --git a/src/Tests/dotnet-MsiInstallation.Tests/WorkloadSetTests.cs b/src/Tests/dotnet-MsiInstallation.Tests/WorkloadSetTests.cs index 994ba0160c49..926688a175c8 100644 --- a/src/Tests/dotnet-MsiInstallation.Tests/WorkloadSetTests.cs +++ b/src/Tests/dotnet-MsiInstallation.Tests/WorkloadSetTests.cs @@ -7,6 +7,7 @@ using System.Text; using System.Threading.Tasks; using Microsoft.DotNet.MsiInstallerTests.Framework; +using Microsoft.NET.Sdk.WorkloadManifestReader; namespace Microsoft.DotNet.MsiInstallerTests { @@ -65,11 +66,8 @@ public void DoesNotUseWorkloadSetsByDefault() } - [Fact] - public void UpdateWithWorkloadSets() + void UpdateAndSwitchToWorkloadSetMode(out string updatedWorkloadVersion, out WorkloadSet rollbackAfterUpdate) { - InstallSdk(); - var originalWorkloadVersion = GetWorkloadVersion(); originalWorkloadVersion.Should().StartWith("8.0.200-manifests."); @@ -78,17 +76,11 @@ public void UpdateWithWorkloadSets() .Should() .Pass(); - var originalRollback = GetRollback(); - var updatedWorkloadVersion = GetWorkloadVersion(); + rollbackAfterUpdate = GetRollback(); + updatedWorkloadVersion = GetWorkloadVersion(); updatedWorkloadVersion.Should().StartWith("8.0.200-manifests."); updatedWorkloadVersion.Should().NotBe(originalWorkloadVersion); - VM.CreateRunCommand("dotnet", "nuget", "add", "source", @"c:\SdkTesting\WorkloadSets") - .WithDescription("Add WorkloadSets to NuGet.config") - .Execute() - .Should() - .Pass(); - GetUpdateMode().Should().Be("manifests"); VM.CreateRunCommand("dotnet", "workload", "config", "--update-mode", "workload-set") @@ -100,18 +92,50 @@ public void UpdateWithWorkloadSets() GetWorkloadVersion().Should().Be(updatedWorkloadVersion); GetUpdateMode().Should().Be("workload-set"); + } - VM.CreateRunCommand("dotnet", "workload", "update") + [Fact] + public void UpdateWithWorkloadSets() + { + InstallSdk(); + + UpdateAndSwitchToWorkloadSetMode(out string _, out WorkloadSet rollbackAfterUpdate); + + VM.CreateRunCommand("dotnet", "nuget", "add", "source", @"c:\SdkTesting\WorkloadSets") + .WithDescription("Add WorkloadSets to NuGet.config") .Execute() .Should() .Pass(); + VM.CreateRunCommand("dotnet", "workload", "update") + .Execute() + .Should() + .Pass(); + var newRollback = GetRollback(); - newRollback.ManifestVersions.Should().NotBeEquivalentTo(originalRollback.ManifestVersions); + newRollback.ManifestVersions.Should().NotBeEquivalentTo(rollbackAfterUpdate.ManifestVersions); GetWorkloadVersion().Should().Be("8.0.201"); + } + + [Fact] + public void UpdateInWorkloadSetModeWithNoAvailableWorkloadSet() + { + InstallSdk(); + UpdateAndSwitchToWorkloadSetMode(out string updatedWorkloadVersion, out WorkloadSet rollbackAfterUpdate); + + VM.CreateRunCommand("dotnet", "workload", "update") + .Execute() + .Should() + .Pass(); + + var newRollback = GetRollback(); + + newRollback.ManifestVersions.Should().BeEquivalentTo(rollbackAfterUpdate.ManifestVersions); + + GetWorkloadVersion().Should().Be(updatedWorkloadVersion); } string GetWorkloadVersion()