From 9eac17a8ab63f157253a74828b0fbd593f53d71a Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Sun, 25 Apr 2021 23:35:50 -0500 Subject: Add tests for #5253 and #5586. --- src/WixToolsetTest.BurnE2E/CacheTests.cs | 106 +++++++++++++++++++++++++++++++ 1 file changed, 106 insertions(+) create mode 100644 src/WixToolsetTest.BurnE2E/CacheTests.cs (limited to 'src/WixToolsetTest.BurnE2E/CacheTests.cs') diff --git a/src/WixToolsetTest.BurnE2E/CacheTests.cs b/src/WixToolsetTest.BurnE2E/CacheTests.cs new file mode 100644 index 00000000..f62b0874 --- /dev/null +++ b/src/WixToolsetTest.BurnE2E/CacheTests.cs @@ -0,0 +1,106 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolsetTest.BurnE2E +{ + using System.Collections.Generic; + using System.IO; + using WixBuildTools.TestSupport; + using WixToolset.Mba.Core; + using Xunit; + using Xunit.Abstractions; + + public class CacheTests : BurnE2ETests + { + public CacheTests(ITestOutputHelper testOutputHelper) : base(testOutputHelper) { } + + [Fact] + public void CanDownloadPayloadsFromMissingAttachedContainer() + { + var packageA = this.CreatePackageInstaller("PackageA"); + var packageB = this.CreatePackageInstaller("PackageB"); + var bundleA = this.CreateBundleInstaller("BundleA"); + var testBAController = this.CreateTestBAController(); + var webServer = this.CreateWebServer(); + + webServer.AddFiles(new Dictionary + { + { "/BundleA/PackageA.msi", Path.Combine(this.TestContext.TestDataFolder, "PackageA.msi") }, + { "/BundleA/PackageB.msi", Path.Combine(this.TestContext.TestDataFolder, "PackageB.msi") }, + }); + webServer.Start(); + + // Don't install PackageB initially so it will be installed when run from the package cache. + testBAController.SetPackageRequestedState("PackageB", RequestState.Absent); + + packageA.VerifyInstalled(false); + packageB.VerifyInstalled(false); + + // Manually copy bundle to separate directory, install from there, and then delete it + // so that when run from the package cache, it can't find the attached container. + using (var dfs = new DisposableFileSystem()) + { + var tempDirectory = dfs.GetFolder(true); + + var bundleAFileInfo = new FileInfo(bundleA.Bundle); + var bundleACopiedPath = Path.Combine(tempDirectory, bundleAFileInfo.Name); + bundleAFileInfo.CopyTo(bundleACopiedPath); + + bundleA.Install(bundleACopiedPath); + } + + var bundlePackageCachePath = bundleA.VerifyRegisteredAndInPackageCache(); + + packageA.VerifyInstalled(true); + packageB.VerifyInstalled(false); + + testBAController.SetPackageRequestedState("PackageB", RequestState.Present); + + bundleA.Modify(bundlePackageCachePath); + bundleA.VerifyRegisteredAndInPackageCache(); + + packageA.VerifyInstalled(true); + packageB.VerifyInstalled(true); + } + + [Fact] + public void CanFindAttachedContainerFromRenamedBundle() + { + var packageA = this.CreatePackageInstaller("PackageA"); + var packageB = this.CreatePackageInstaller("PackageB"); + var bundleB = this.CreateBundleInstaller("BundleB"); + var testBAController = this.CreateTestBAController(); + + // Don't install PackageB initially so it will be installed when run from the package cache. + testBAController.SetPackageRequestedState("PackageB", RequestState.Absent); + + packageA.VerifyInstalled(false); + packageB.VerifyInstalled(false); + + // Manually copy bundle to separate directory with new name and install from there + // so that when run from the package cache, it has to get the attached container from the renamed bundle. + using (var dfs = new DisposableFileSystem()) + { + var tempDirectory = dfs.GetFolder(true); + + var bundleBFileInfo = new FileInfo(bundleB.Bundle); + var bundleBCopiedPath = Path.Combine(tempDirectory, "RenamedBundle.exe"); + bundleBFileInfo.CopyTo(bundleBCopiedPath); + + bundleB.Install(bundleBCopiedPath); + + var bundlePackageCachePath = bundleB.VerifyRegisteredAndInPackageCache(); + + packageA.VerifyInstalled(true); + packageB.VerifyInstalled(false); + + testBAController.SetPackageRequestedState("PackageB", RequestState.Present); + + bundleB.Modify(bundlePackageCachePath); + bundleB.VerifyRegisteredAndInPackageCache(); + + packageA.VerifyInstalled(true); + packageB.VerifyInstalled(true); + } + } + } +} -- cgit v1.2.3-55-g6feb