mirror of
https://github.com/velopack/velopack.git
synced 2025-10-25 15:19:22 +00:00
Fix failing tests
This commit is contained in:
@@ -59,7 +59,10 @@ namespace Squirrel
|
||||
//sl.SetToastActivatorCLSID(toastActivatorCLSID);
|
||||
|
||||
this.Log().Info("About to save shortcut: {0} (target {1}, workingDir {2}, args {3})", file, sl.Target, sl.WorkingDirectory, sl.Arguments);
|
||||
if (ModeDetector.InUnitTestRunner() == false) sl.Save(file);
|
||||
|
||||
if (f == ShortcutLocation.AppRoot || !ModeDetector.InUnitTestRunner()) {
|
||||
sl.Save(file);
|
||||
}
|
||||
}), "Can't write shortcut: " + file);
|
||||
}
|
||||
|
||||
|
||||
@@ -222,6 +222,9 @@ namespace Squirrel
|
||||
|
||||
private Task<IDisposable> acquireUpdateLock()
|
||||
{
|
||||
if (!ModeDetector.InUnitTestRunner() && _config.CurrentlyInstalledVersion == null)
|
||||
throw new InvalidOperationException("Cannot perform this operation in a portable app (must be installed first).");
|
||||
|
||||
lock (_lockobj) {
|
||||
if (_disposed) throw new ObjectDisposedException(nameof(UpdateManager));
|
||||
if (_updateLock != null) return Task.FromResult(_updateLock);
|
||||
|
||||
@@ -256,7 +256,7 @@ namespace Squirrel.Tests
|
||||
"Squirrel.Core.1.1.0.0-full.nupkg",
|
||||
}.ForEach(x => File.Copy(IntegrationTestHelper.GetPath("fixtures", x), Path.Combine(packagesDir, x)));
|
||||
|
||||
using var fixture = UpdateManagerTestImpl.FromLocalPackageTempDir(null, APP_ID, tempDir);
|
||||
using var fixture = UpdateManagerTestImpl.FromLocalPackageTempDir("", APP_ID, tempDir);
|
||||
|
||||
var baseEntry = ReleaseEntry.GenerateFromFile(Path.Combine(packagesDir, "Squirrel.Core.1.0.0.0-full.nupkg"));
|
||||
var latestFullEntry = ReleaseEntry.GenerateFromFile(Path.Combine(packagesDir, "Squirrel.Core.1.1.0.0-full.nupkg"));
|
||||
@@ -308,7 +308,7 @@ namespace Squirrel.Tests
|
||||
"Squirrel.Core.1.2.0.0-full.nupkg",
|
||||
}.ForEach(x => File.Copy(IntegrationTestHelper.GetPath("fixtures", x), Path.Combine(packagesDir, x)));
|
||||
|
||||
using var fixture = UpdateManagerTestImpl.FromLocalPackageTempDir(null, APP_ID, tempDir);
|
||||
using var fixture = UpdateManagerTestImpl.FromLocalPackageTempDir("", APP_ID, tempDir);
|
||||
|
||||
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"));
|
||||
@@ -359,7 +359,7 @@ namespace Squirrel.Tests
|
||||
"Squirrel.Core.1.3.0.0-full.nupkg",
|
||||
}.ForEach(x => File.Copy(IntegrationTestHelper.GetPath("fixtures", x), Path.Combine(packagesDir, x)));
|
||||
|
||||
using var fixture = UpdateManagerTestImpl.FromLocalPackageTempDir(null, APP_ID, tempDir);
|
||||
using var fixture = UpdateManagerTestImpl.FromLocalPackageTempDir("", APP_ID, tempDir);
|
||||
|
||||
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.3.0.0-full.nupkg"));
|
||||
@@ -413,7 +413,7 @@ namespace Squirrel.Tests
|
||||
"Squirrel.Core.1.1.0.0-full.nupkg",
|
||||
}.ForEach(x => File.Copy(IntegrationTestHelper.GetPath("fixtures", x), Path.Combine(packagesDir, x)));
|
||||
|
||||
using var fixture = UpdateManagerTestImpl.FromLocalPackageTempDir(null, APP_ID, tempDir);
|
||||
using var fixture = UpdateManagerTestImpl.FromLocalPackageTempDir("", APP_ID, tempDir);
|
||||
|
||||
var baseEntry = ReleaseEntry.GenerateFromFile(Path.Combine(packagesDir, "Squirrel.Core.1.0.0.0-full.nupkg"));
|
||||
var deltaEntry = ReleaseEntry.GenerateFromFile(Path.Combine(packagesDir, "Squirrel.Core.1.1.0.0-delta.nupkg"));
|
||||
@@ -463,7 +463,7 @@ namespace Squirrel.Tests
|
||||
"Squirrel.Core.1.1.0.0-delta.nupkg"
|
||||
}.ForEach(x => File.Copy(IntegrationTestHelper.GetPath("fixtures", x), Path.Combine(tempDir, APP_ID, "packages", x)));
|
||||
|
||||
using var fixture = UpdateManagerTestImpl.FromLocalPackageTempDir(null, APP_ID, tempDir);
|
||||
using var fixture = UpdateManagerTestImpl.FromLocalPackageTempDir("", APP_ID, tempDir);
|
||||
|
||||
var baseEntry = ReleaseEntry.GenerateFromFile(Path.Combine(tempDir, APP_ID, "packages", "Squirrel.Core.1.0.0.0-full.nupkg"));
|
||||
var deltaEntry = ReleaseEntry.GenerateFromFile(Path.Combine(tempDir, APP_ID, "packages", "Squirrel.Core.1.1.0.0-delta.nupkg"));
|
||||
@@ -490,7 +490,7 @@ namespace Squirrel.Tests
|
||||
fixture.CreateShortcutsForExecutable("SquirrelAwareApp.exe",
|
||||
ShortcutLocation.Desktop | ShortcutLocation.StartMenu | ShortcutLocation.Startup | ShortcutLocation.AppRoot, false, null, null);
|
||||
|
||||
Assert.True(File.Exists(Path.Combine(tempDir, APP_ID, "SquirrelAwareApp.lnk")));
|
||||
Assert.True(File.Exists(Path.Combine(tempDir, APP_ID, "PublishSingleFileAwareApp.lnk")));
|
||||
|
||||
// NB: COM is Weird.
|
||||
Thread.Sleep(1000);
|
||||
|
||||
@@ -13,10 +13,11 @@ namespace Squirrel.Tests.TestHelpers
|
||||
|
||||
public static UpdateManagerTestImpl FromLocalPackageTempDir(string updatePackageDir, string appId, string installTempDir)
|
||||
{
|
||||
return FromLocalPackageTempDir(new DirectoryInfo(updatePackageDir), appId, installTempDir);
|
||||
var di = String.IsNullOrWhiteSpace(updatePackageDir) ? null : new DirectoryInfo(updatePackageDir);
|
||||
return FromLocalPackageTempDir(di, appId, installTempDir);
|
||||
}
|
||||
|
||||
private static UpdateManagerTestImpl FromLocalPackageTempDir(DirectoryInfo updatePackageDir, string appId, string installTempDir)
|
||||
public static UpdateManagerTestImpl FromLocalPackageTempDir(DirectoryInfo updatePackageDir, string appId, string installTempDir)
|
||||
{
|
||||
var appPath = Path.Combine(installTempDir, appId);
|
||||
Directory.CreateDirectory(appPath);
|
||||
|
||||
@@ -13,6 +13,7 @@ using System.Net;
|
||||
using Squirrel.NuGet;
|
||||
using System.Net.Http;
|
||||
using NuGet.Versioning;
|
||||
using Squirrel.Sources;
|
||||
|
||||
namespace Squirrel.Tests
|
||||
{
|
||||
@@ -250,7 +251,7 @@ namespace Squirrel.Tests
|
||||
{
|
||||
using var _1 = Utility.GetTempDirectory(out var tempDir);
|
||||
var directory = Path.Combine(tempDir, "missing-folder");
|
||||
using var fixture = new UpdateManager(directory);
|
||||
using var fixture = UpdateManagerTestImpl.FromLocalPackageTempDir(directory, APP_ID, tempDir);
|
||||
await Assert.ThrowsAsync<Exception>(() => fixture.CheckForUpdate());
|
||||
}
|
||||
|
||||
@@ -258,7 +259,9 @@ namespace Squirrel.Tests
|
||||
public async Task WhenReleasesFileDoesntExistThrowACustomError()
|
||||
{
|
||||
using var _1 = Utility.GetTempDirectory(out var tempDir);
|
||||
using var fixture = new UpdateManager(tempDir);
|
||||
var directory = Path.Combine(tempDir, "folder");
|
||||
Directory.CreateDirectory(directory);
|
||||
using var fixture = UpdateManagerTestImpl.FromLocalPackageTempDir(directory, APP_ID, tempDir);
|
||||
await Assert.ThrowsAsync<Exception>(() => fixture.CheckForUpdate());
|
||||
}
|
||||
|
||||
@@ -266,8 +269,10 @@ namespace Squirrel.Tests
|
||||
public async Task WhenReleasesFileIsBlankThrowAnException()
|
||||
{
|
||||
using var _1 = Utility.GetTempDirectory(out var tempDir);
|
||||
using var fixture = new UpdateManager(tempDir);
|
||||
File.WriteAllText(Path.Combine(tempDir, "RELEASES"), "");
|
||||
var directory = Path.Combine(tempDir, "folder");
|
||||
Directory.CreateDirectory(directory);
|
||||
using var fixture = UpdateManagerTestImpl.FromLocalPackageTempDir(directory, APP_ID, tempDir);
|
||||
File.WriteAllText(Path.Combine(directory, "RELEASES"), "");
|
||||
await Assert.ThrowsAsync(typeof(Exception), () => fixture.CheckForUpdate());
|
||||
}
|
||||
|
||||
@@ -275,7 +280,8 @@ namespace Squirrel.Tests
|
||||
public async Task WhenUrlResultsInWebExceptionWeShouldThrow()
|
||||
{
|
||||
// This should result in a WebException (which gets caught) unless you can actually access http://lol
|
||||
using var fixture = new UpdateManager("http://lol");
|
||||
using var _1 = Utility.GetTempDirectory(out var tempDir);
|
||||
using var fixture = UpdateManagerTestImpl.FromFakeWebSource("http://lol", APP_ID, tempDir);
|
||||
await Assert.ThrowsAsync(typeof(HttpRequestException), () => fixture.CheckForUpdate());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user