public async Task ApplyReleaseWhichRemovesAFile() { string tempDir; using (Utility.WithTempDirectory(out tempDir)) { string appDir = Path.Combine(tempDir, "theApp"); string packagesDir = Path.Combine(appDir, "packages"); Directory.CreateDirectory(packagesDir); new[] { "Squirrel.Core.1.1.0.0-full.nupkg", "Squirrel.Core.1.2.0.0-full.nupkg", }.ForEach(x => File.Copy(IntegrationTestHelper.GetPath("fixtures", x), Path.Combine(packagesDir, x))); var fixture = new UpdateManager.ApplyReleasesImpl(appDir); var baseEntry = ReleaseEntry.GenerateFromFile(Path.Combine(packagesDir, "Squirrel.Core.1.1.0.0-full.nupkg")); var latestFullEntry = ReleaseEntry.GenerateFromFile(Path.Combine(packagesDir, "Squirrel.Core.1.2.0.0-full.nupkg")); var updateInfo = UpdateInfo.Create(baseEntry, new[] { latestFullEntry }, packagesDir); updateInfo.ReleasesToApply.Contains(latestFullEntry).ShouldBeTrue(); var progress = new List <int>(); await fixture.ApplyReleases(updateInfo, false, false, progress.Add); this.Log().Info("Progress: [{0}]", String.Join(",", progress)); progress .Aggregate(0, (acc, x) => { (x >= acc).ShouldBeTrue(); return(x); }) .ShouldEqual(100); var rootDirectory = Path.Combine(tempDir, "theApp", "app-1.2.0.0"); new[] { new { Name = "NLog.dll", Version = new Version("2.0.0.0") }, new { Name = "NSync.Core.dll", Version = new Version("1.1.0.0") }, }.ForEach(x => { var path = Path.Combine(rootDirectory, x.Name); this.Log().Info("Looking for {0}", path); File.Exists(path).ShouldBeTrue(); }); var removedFile = Path.Combine("sub", "Ionic.Zip.dll"); var deployedPath = Path.Combine(rootDirectory, removedFile); File.Exists(deployedPath).ShouldBeFalse(); } }
public async Task WhenTwoRemoteUpdatesAreAvailableChoosesDeltaVersion() { string tempDir; using (Utility.WithTempDirectory(out tempDir)) { var appDir = Path.Combine(tempDir, "theApp"); var localPackages = Path.Combine(appDir, "packages"); var remotePackages = Path.Combine(tempDir, "releases"); Directory.CreateDirectory(localPackages); Directory.CreateDirectory(remotePackages); new[] { "Squirrel.Core.1.0.0.0-full.nupkg", }.ForEach(x => { var path = IntegrationTestHelper.GetPath("fixtures", x); File.Copy(path, Path.Combine(localPackages, x)); }); new[] { "Squirrel.Core.1.0.0.0-full.nupkg", "Squirrel.Core.1.1.0.0-delta.nupkg", "Squirrel.Core.1.1.0.0-full.nupkg", }.ForEach(x => { var path = IntegrationTestHelper.GetPath("fixtures", x); File.Copy(path, Path.Combine(remotePackages, x)); }); var fixture = new UpdateManager.ApplyReleasesImpl(appDir); // sync both release files await fixture.updateLocalReleasesFile(); ReleaseEntry.BuildReleasesFile(remotePackages); using (var mgr = new UpdateManager(remotePackages, "theApp", tempDir, new FakeUrlDownloader())) { UpdateInfo updateInfo; updateInfo = await mgr.CheckForUpdate(); Assert.True(updateInfo.ReleasesToApply.First().IsDelta); updateInfo = await mgr.CheckForUpdate(ignoreDeltaUpdates : true); Assert.False(updateInfo.ReleasesToApply.First().IsDelta); } } }
public async Task WhenRemoteReleasesDoNotHaveDeltasNoUpdatesAreApplied() { string tempDir; using (Utility.WithTempDirectory(out tempDir)) { var appDir = Path.Combine(tempDir, "theApp"); var localPackages = Path.Combine(appDir, "packages"); var remotePackages = Path.Combine(tempDir, "releases"); Directory.CreateDirectory(localPackages); Directory.CreateDirectory(remotePackages); new[] { "Squirrel.Core.1.0.0.0-full.nupkg", "Squirrel.Core.1.1.0.0-delta.nupkg", "Squirrel.Core.1.1.0.0-full.nupkg", }.ForEach(x => { var path = IntegrationTestHelper.GetPath("fixtures", x); File.Copy(path, Path.Combine(localPackages, x)); }); new[] { "Squirrel.Core.1.0.0.0-full.nupkg", "Squirrel.Core.1.1.0.0-full.nupkg", }.ForEach(x => { var path = IntegrationTestHelper.GetPath("fixtures", x); File.Copy(path, Path.Combine(remotePackages, x)); }); var fixture = new UpdateManager.ApplyReleasesImpl(appDir); // sync both release files await fixture.updateLocalReleasesFile(); ReleaseEntry.BuildReleasesFile(remotePackages); UpdateInfo updateInfo; using (var mgr = new UpdateManager(remotePackages, "theApp", tempDir, new FakeUrlDownloader())) { updateInfo = await mgr.CheckForUpdate(); } Assert.NotNull(updateInfo); Assert.Empty(updateInfo.ReleasesToApply); } }
public async Task GetShortcutsSmokeTest() { string remotePkgPath; string path; using (Utility.WithTempDirectory(out path)) { using (Utility.WithTempDirectory(out remotePkgPath)) using (var mgr = new UpdateManager(remotePkgPath, "theApp", path)) { IntegrationTestHelper.CreateFakeInstalledApp("1.0.0.1", remotePkgPath); await mgr.FullInstall(); } var fixture = new UpdateManager.ApplyReleasesImpl(Path.Combine(path, "theApp")); var result = fixture.GetShortcutsForExecutable("SquirrelAwareApp.exe", ShortcutLocation.Desktop | ShortcutLocation.StartMenu | ShortcutLocation.Startup, null); Assert.Equal(3, result.Keys.Count); // NB: Squirrel-Aware first-run might still be running, slow // our roll before blowing away the temp path Thread.Sleep(1000); } }
public async Task CreateShortcutsRoundTrip() { string remotePkgPath; string path; using (Utility.WithTempDirectory(out path)) { using (Utility.WithTempDirectory(out remotePkgPath)) using (var mgr = new UpdateManager(remotePkgPath, "theApp", path)) { IntegrationTestHelper.CreateFakeInstalledApp("1.0.0.1", remotePkgPath); await mgr.FullInstall(); } var fixture = new UpdateManager.ApplyReleasesImpl(Path.Combine(path, "theApp")); fixture.CreateShortcutsForExecutable("SquirrelAwareApp.exe", ShortcutLocation.Desktop | ShortcutLocation.StartMenu | ShortcutLocation.Startup | ShortcutLocation.AppRoot, false, null, null); // NB: COM is Weird. Thread.Sleep(1000); fixture.RemoveShortcutsForExecutable("SquirrelAwareApp.exe", ShortcutLocation.Desktop | ShortcutLocation.StartMenu | ShortcutLocation.Startup | ShortcutLocation.AppRoot); // NB: Squirrel-Aware first-run might still be running, slow // our roll before blowing away the temp path Thread.Sleep(1000); } }