From 374996f481f17df356ec7df1b831eb78819efdc2 Mon Sep 17 00:00:00 2001 From: Caelan Sayler Date: Sun, 31 Dec 2023 11:23:38 +0000 Subject: [PATCH] Remove more usages of "Squirrel" --- src/Velopack.Deployment/GitHubRepository.cs | 2 +- .../SimpleWebRepository.cs | 2 +- .../Commands/OsxReleasifyCommandRunner.cs | 4 +- src/Velopack.Packaging.OSX/HelperExe.cs | 4 +- .../Commands/WindowsReleasifyCommandRunner.cs | 4 +- src/Velopack.Packaging/NugetConsole.cs | 4 +- src/Velopack.Vpk/Commands/OsxBundleCommand.cs | 2 +- .../Commands/OsxReleasifyCommand.cs | 4 +- .../Commands/WindowsPackCommand.cs | 2 +- .../Commands/WindowsReleasifyCommand.cs | 4 +- src/Velopack.Vpk/Commands/_OutputCommand.cs | 2 +- src/Velopack.Vpk/Compat/RunnerFactory.cs | 15 +- ...VersionLocator.cs => SdkVersionLocator.cs} | 4 +- src/Velopack.Vpk/Program.cs | 4 +- src/Velopack.Vpk/Updates/UpdateChecker.cs | 2 +- .../Locators/WindowsVelopackLocator.cs | 2 +- src/Velopack/NuGet/NuspecManifest.cs | 2 +- src/Velopack/ReleaseEntry.cs | 2 +- src/Velopack/Sources/GithubSource.cs | 2 +- src/Velopack/Sources/GitlabSource.cs | 2 +- .../Sources/HttpClientFileDownloader.cs | 4 +- src/Velopack/UpdateManager.cs | 4 +- src/Velopack/VelopackApp.cs | 44 +- src/Velopack/VelopackRuntimeInfo.cs | 20 +- src/Velopack/Windows/RuntimeInfo.cs | 2 +- test/Velopack.Packaging.Tests/Init.cs | 2 +- .../UpdateManager/ApplyReleasesTests.cs | 527 ------------------ .../UpdateManager/CheckForUpdateTests.cs | 178 ------ .../UpdateManager/DownloadReleasesTests.cs | 194 ------- .../UpdateManager/UpdateManagerTests.cs | 367 ------------ 30 files changed, 73 insertions(+), 1338 deletions(-) rename src/Velopack.Vpk/Compat/{SquirrelVersionLocator.cs => SdkVersionLocator.cs} (97%) delete mode 100644 test/Velopack.Tests/UpdateManager/ApplyReleasesTests.cs delete mode 100644 test/Velopack.Tests/UpdateManager/CheckForUpdateTests.cs delete mode 100644 test/Velopack.Tests/UpdateManager/DownloadReleasesTests.cs delete mode 100644 test/Velopack.Tests/UpdateManager/UpdateManagerTests.cs diff --git a/src/Velopack.Deployment/GitHubRepository.cs b/src/Velopack.Deployment/GitHubRepository.cs index 6d6c4f58..8915b7ee 100644 --- a/src/Velopack.Deployment/GitHubRepository.cs +++ b/src/Velopack.Deployment/GitHubRepository.cs @@ -91,7 +91,7 @@ public class GitHubRepository var repoOwner = repoParts[0]; var repoName = repoParts[1]; - var client = new GitHubClient(new ProductHeaderValue("Clowd.Squirrel")) { + var client = new GitHubClient(new ProductHeaderValue("Velopack")) { Credentials = new Credentials(options.Token) }; diff --git a/src/Velopack.Deployment/SimpleWebRepository.cs b/src/Velopack.Deployment/SimpleWebRepository.cs index 5d93e5b2..71737e3b 100644 --- a/src/Velopack.Deployment/SimpleWebRepository.cs +++ b/src/Velopack.Deployment/SimpleWebRepository.cs @@ -45,7 +45,7 @@ public class SimpleWebRepository { _logger.Info($"Trying to download RELEASES index from {uri}"); - var userAgent = new System.Net.Http.Headers.ProductInfoHeaderValue("Squirrel", Assembly.GetExecutingAssembly().GetName().Version.ToString()); + var userAgent = new System.Net.Http.Headers.ProductInfoHeaderValue("Velopack", Assembly.GetExecutingAssembly().GetName().Version.ToString()); using (HttpClient client = new HttpClient()) { client.DefaultRequestHeaders.UserAgent.Add(userAgent); return await client.GetStringAsync(uri); diff --git a/src/Velopack.Packaging.OSX/Commands/OsxReleasifyCommandRunner.cs b/src/Velopack.Packaging.OSX/Commands/OsxReleasifyCommandRunner.cs index f3971ee2..2da3d143 100644 --- a/src/Velopack.Packaging.OSX/Commands/OsxReleasifyCommandRunner.cs +++ b/src/Velopack.Packaging.OSX/Commands/OsxReleasifyCommandRunner.cs @@ -42,7 +42,7 @@ public class OsxReleasifyCommandRunner } var appBundlePath = options.BundleDirectory; - _logger.Info("Creating Squirrel application from app bundle at: " + appBundlePath); + _logger.Info("Creating application from app bundle at: " + appBundlePath); _logger.Info("Parsing app Info.plist"); var contentsDir = Path.Combine(appBundlePath, "Contents"); @@ -108,7 +108,7 @@ public class OsxReleasifyCommandRunner helper.CreateDittoZip(appBundlePath, zipPath); // create release / delta from notarized .app - _logger.Info("Creating Squirrel Release"); + _logger.Info("Creating Release"); using var _ = Utility.GetTempDirectory(out var tmp); var nuget = new NugetConsole(_logger); var nupkgPath = nuget.CreatePackageFromNuspecPath(tmp, appBundlePath, nuspecPath); diff --git a/src/Velopack.Packaging.OSX/HelperExe.cs b/src/Velopack.Packaging.OSX/HelperExe.cs index 5f4036dc..5abdb21a 100644 --- a/src/Velopack.Packaging.OSX/HelperExe.cs +++ b/src/Velopack.Packaging.OSX/HelperExe.cs @@ -13,7 +13,7 @@ public class HelperExe : HelperFile { } - public string SquirrelEntitlements => FindHelperFile("Squirrel.entitlements"); + public string VelopackEntitlements => FindHelperFile("Velopack.entitlements"); [SupportedOSPlatform("osx")] public void CodeSign(string identity, string entitlements, string filePath) @@ -21,7 +21,7 @@ public class HelperExe : HelperFile if (String.IsNullOrEmpty(entitlements)) { Log.Info("No codesign entitlements provided, using default dotnet entitlements: " + "https://docs.microsoft.com/en-us/dotnet/core/install/macos-notarization-issues"); - entitlements = SquirrelEntitlements; + entitlements = VelopackEntitlements; } if (!File.Exists(entitlements)) { diff --git a/src/Velopack.Packaging.Windows/Commands/WindowsReleasifyCommandRunner.cs b/src/Velopack.Packaging.Windows/Commands/WindowsReleasifyCommandRunner.cs index 29067ba6..dbcc3fd6 100644 --- a/src/Velopack.Packaging.Windows/Commands/WindowsReleasifyCommandRunner.cs +++ b/src/Velopack.Packaging.Windows/Commands/WindowsReleasifyCommandRunner.cs @@ -98,7 +98,7 @@ public class WindowsReleasifyCommandRunner // fail the release if this is a clickonce application if (Directory.EnumerateFiles(libDir, "*.application").Any(f => File.ReadAllText(f).Contains("clickonce"))) { throw new ArgumentException( - "Squirrel does not support building releases for ClickOnce applications. " + + "Velopack does not support building releases for ClickOnce applications. " + "Please publish your application to a folder without ClickOnce."); } @@ -106,7 +106,7 @@ public class WindowsReleasifyCommandRunner // copy Update.exe into package, so it can also be updated in both full/delta packages // and do it before signing so that Update.exe will also be signed. It is renamed to - // 'Squirrel.exe' only because Squirrel.Windows expects it to be called this. + // 'Squirrel.exe' only because Squirrel.Windows and Clowd.Squirrel expects it to be called this. File.Copy(updatePath, Path.Combine(libDir, "Squirrel.exe"), true); // sign all exe's in this package diff --git a/src/Velopack.Packaging/NugetConsole.cs b/src/Velopack.Packaging/NugetConsole.cs index 24feace5..809d787e 100644 --- a/src/Velopack.Packaging/NugetConsole.cs +++ b/src/Velopack.Packaging/NugetConsole.cs @@ -44,7 +44,7 @@ public class NugetConsole {releaseNotesText} - + ".Trim(); @@ -54,7 +54,7 @@ public class NugetConsole public string CreatePackageFromNuspecPath(string tempDir, string packDir, string nuspecPath) { - var nup = Path.Combine(tempDir, "squirreltemp.nuspec"); + var nup = Path.Combine(tempDir, "velotemp.nuspec"); File.Copy(nuspecPath, nup); Pack(nup, packDir, tempDir); diff --git a/src/Velopack.Vpk/Commands/OsxBundleCommand.cs b/src/Velopack.Vpk/Commands/OsxBundleCommand.cs index 3643d7ca..d24e60df 100644 --- a/src/Velopack.Vpk/Commands/OsxBundleCommand.cs +++ b/src/Velopack.Vpk/Commands/OsxBundleCommand.cs @@ -22,7 +22,7 @@ public class OsxBundleCommand : OutputCommand : base("bundle", "Create's an OSX .app bundle from a folder containing application files.") { AddOption((v) => PackId = v, "--packId", "-u") - .SetDescription("Unique Squirrel Id for application bundle.") + .SetDescription("Unique Id for application bundle.") .SetArgumentHelpName("ID") .SetRequired() .RequiresValidNuGetId(); diff --git a/src/Velopack.Vpk/Commands/OsxReleasifyCommand.cs b/src/Velopack.Vpk/Commands/OsxReleasifyCommand.cs index d59fa324..3ff9f2ed 100644 --- a/src/Velopack.Vpk/Commands/OsxReleasifyCommand.cs +++ b/src/Velopack.Vpk/Commands/OsxReleasifyCommand.cs @@ -33,10 +33,10 @@ public class OsxReleasifyCommand : PlatformCommand public string Channel { get; private set; } public OsxReleasifyCommand() - : base("releasify", "Converts an application bundle into a Squirrel release and installer.") + : base("releasify", "Converts an application bundle into a release and installer.") { AddOption((v) => BundleDirectory = v.ToFullNameOrNull(), "-b", "--bundle") - .SetDescription("The bundle to convert into a Squirrel release.") + .SetDescription("The bundle to convert into a release.") .SetArgumentHelpName("PATH") .MustNotBeEmpty() .RequiresExtension(".app") diff --git a/src/Velopack.Vpk/Commands/WindowsPackCommand.cs b/src/Velopack.Vpk/Commands/WindowsPackCommand.cs index e085fef7..06a071d2 100644 --- a/src/Velopack.Vpk/Commands/WindowsPackCommand.cs +++ b/src/Velopack.Vpk/Commands/WindowsPackCommand.cs @@ -20,7 +20,7 @@ public class WindowsPackCommand : WindowsReleasifyCommand, INugetPackCommand public string ReleaseNotes { get; private set; } public WindowsPackCommand() - : base("pack", "Creates a Squirrel release from a folder containing application files.") + : base("pack", "Creates a release from a folder containing application files.") { AddOption((v) => PackId = v, "--packId", "-u") .SetDescription("Unique Id for application bundle.") diff --git a/src/Velopack.Vpk/Commands/WindowsReleasifyCommand.cs b/src/Velopack.Vpk/Commands/WindowsReleasifyCommand.cs index efca55c5..4f529a78 100644 --- a/src/Velopack.Vpk/Commands/WindowsReleasifyCommand.cs +++ b/src/Velopack.Vpk/Commands/WindowsReleasifyCommand.cs @@ -19,7 +19,7 @@ public class WindowsReleasifyCommand : WindowsSigningCommand public string Channel { get; private set; } public WindowsReleasifyCommand() - : this("releasify", "Take an existing nuget package and convert it into a Squirrel release.") + : this("releasify", "Take an existing nuget package and convert it into a release.") { AddOption((v) => Package = v.ToFullNameOrNull(), "-p", "--package") .SetDescription("Path to a '.nupkg' package to releasify.") @@ -31,7 +31,7 @@ public class WindowsReleasifyCommand : WindowsSigningCommand /// /// This constructor is used by the pack command, which requires all the same properties but - /// does not allow the user to provide the Package (it is created/populated by Squirrel). + /// does not allow the user to provide the Package (it is created/populated by Velopack). /// protected WindowsReleasifyCommand(string name, string description) : base(name, description) diff --git a/src/Velopack.Vpk/Commands/_OutputCommand.cs b/src/Velopack.Vpk/Commands/_OutputCommand.cs index e210487f..42078b02 100644 --- a/src/Velopack.Vpk/Commands/_OutputCommand.cs +++ b/src/Velopack.Vpk/Commands/_OutputCommand.cs @@ -16,7 +16,7 @@ namespace Velopack.Vpk.Commands : base(name, description) { ReleaseDirectoryOption = AddOption((v) => ReleaseDirectory = v.ToFullNameOrNull(), "-o", "--outputDir") - .SetDescription("Output directory for Squirrel packages.") + .SetDescription("Output directory for created packages.") .SetArgumentHelpName("DIR") .SetDefault(new DirectoryInfo(".\\Releases")); } diff --git a/src/Velopack.Vpk/Compat/RunnerFactory.cs b/src/Velopack.Vpk/Compat/RunnerFactory.cs index 9a9a7ae7..45baf3a5 100644 --- a/src/Velopack.Vpk/Compat/RunnerFactory.cs +++ b/src/Velopack.Vpk/Compat/RunnerFactory.cs @@ -7,6 +7,7 @@ namespace Velopack.Vpk.Compat; public class RunnerFactory { private const string CLOWD_PACKAGE_NAME = "Clowd.Squirrel"; + private const string NUGET_PACKAGE_NAME = "Velopack"; private readonly ILogger _logger; private readonly IConfiguration _config; @@ -41,12 +42,12 @@ public class RunnerFactory throw new Exception($"Could not find '.sln'. Specify solution or solution directory with '--solution='."); } - var version = new SquirrelVersionLocator(_logger).Search(solutionDir, CLOWD_PACKAGE_NAME); + var version = new SdkVersionLocator(_logger).Search(solutionDir, NUGET_PACKAGE_NAME); if (version.Major == 4) { - var myVer = VelopackRuntimeInfo.SquirrelNugetVersion; + var myVer = VelopackRuntimeInfo.VelopackNugetVersion; if (version != myVer) { - _logger.Warn($"Installed SDK is {version}, while csq is {myVer}, this is not recommended."); + _logger.Warn($"Installed SDK is {version}, while vpk is {myVer}, this is not recommended."); } return new EmbeddedRunner(_logger); } @@ -56,14 +57,14 @@ public class RunnerFactory Dictionary packageSearchPaths = new(); var nugetPackagesDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".nuget", "packages"); - packageSearchPaths.Add("nuget user profile cache", Path.Combine(nugetPackagesDir, CLOWD_PACKAGE_NAME.ToLower(), "{0}", "tools")); - packageSearchPaths.Add("visual studio packages cache", Path.Combine(solutionDir, "packages", CLOWD_PACKAGE_NAME + ".{0}", "tools")); + packageSearchPaths.Add("nuget user profile cache", Path.Combine(nugetPackagesDir, NUGET_PACKAGE_NAME.ToLower(), "{0}", "tools")); + packageSearchPaths.Add("visual studio packages cache", Path.Combine(solutionDir, "packages", NUGET_PACKAGE_NAME + ".{0}", "tools")); string squirrelExe = null; foreach (var kvp in packageSearchPaths) { var path = String.Format(kvp.Value, version); if (Directory.Exists(path)) { - _logger.Debug($"Found {CLOWD_PACKAGE_NAME} {version} from {kvp.Key}"); + _logger.Debug($"Found {NUGET_PACKAGE_NAME} {version} from {kvp.Key}"); var toolExePath = Path.Combine(path, "Squirrel.exe"); if (File.Exists(toolExePath)) { squirrelExe = toolExePath; @@ -73,7 +74,7 @@ public class RunnerFactory } if (squirrelExe is null) { - throw new Exception($"Could not find {CLOWD_PACKAGE_NAME} {version} Squirrel.exe"); + throw new Exception($"Could not find {NUGET_PACKAGE_NAME} {version} Squirrel.exe"); } return new V2CompatRunner(_logger, squirrelExe); diff --git a/src/Velopack.Vpk/Compat/SquirrelVersionLocator.cs b/src/Velopack.Vpk/Compat/SdkVersionLocator.cs similarity index 97% rename from src/Velopack.Vpk/Compat/SquirrelVersionLocator.cs rename to src/Velopack.Vpk/Compat/SdkVersionLocator.cs index 21fbe176..1c4527bb 100644 --- a/src/Velopack.Vpk/Compat/SquirrelVersionLocator.cs +++ b/src/Velopack.Vpk/Compat/SdkVersionLocator.cs @@ -4,11 +4,11 @@ using NuGet.Versioning; namespace Velopack.Vpk.Compat; -public class SquirrelVersionLocator +public class SdkVersionLocator { private readonly ILogger _logger; - public SquirrelVersionLocator(ILogger logger) + public SdkVersionLocator(ILogger logger) { _logger = logger; } diff --git a/src/Velopack.Vpk/Program.cs b/src/Velopack.Vpk/Program.cs index aaa5c3a4..a2feb811 100644 --- a/src/Velopack.Vpk/Program.cs +++ b/src/Velopack.Vpk/Program.cs @@ -28,7 +28,7 @@ public class Program bool verbose = parseResult.GetValue(VerboseOption); var builder = Host.CreateEmptyApplicationBuilder(new HostApplicationBuilderSettings { - ApplicationName = "Clowd.Squirrel", + ApplicationName = "Velopack", EnvironmentName = "Production", ContentRootPath = Environment.CurrentDirectory, Configuration = new ConfigurationManager(), @@ -51,7 +51,7 @@ public class Program Runner = new RunnerFactory(logger, host.Services.GetRequiredService()); CliRootCommand rootCommand = new CliRootCommand( - $"Squirrel {VelopackRuntimeInfo.SquirrelDisplayVersion} for creating and distributing Squirrel releases.") { + $"Velopack CLI {VelopackRuntimeInfo.VelopackDisplayVersion} for creating and distributing releases.") { VerboseOption, }; diff --git a/src/Velopack.Vpk/Updates/UpdateChecker.cs b/src/Velopack.Vpk/Updates/UpdateChecker.cs index e75e64be..07f8c09d 100644 --- a/src/Velopack.Vpk/Updates/UpdateChecker.cs +++ b/src/Velopack.Vpk/Updates/UpdateChecker.cs @@ -16,7 +16,7 @@ public class UpdateChecker { try { var cancel = new CancellationTokenSource(3000); - var myVer = VelopackRuntimeInfo.SquirrelNugetVersion; + var myVer = VelopackRuntimeInfo.VelopackNugetVersion; var dl = new NugetDownloader(new NugetLoggingWrapper(_logger)); var package = await dl.GetPackageMetadata("csq", (myVer.IsPrerelease || myVer.HasMetadata) ? "pre" : "latest", cancel.Token).ConfigureAwait(false); if (package.Identity.Version > myVer) diff --git a/src/Velopack/Locators/WindowsVelopackLocator.cs b/src/Velopack/Locators/WindowsVelopackLocator.cs index 5d5f2955..89fdca88 100644 --- a/src/Velopack/Locators/WindowsVelopackLocator.cs +++ b/src/Velopack/Locators/WindowsVelopackLocator.cs @@ -9,7 +9,7 @@ using Velopack.NuGet; namespace Velopack.Locators { /// - /// An implementation for Windows which uses the Squirrel default paths. + /// An implementation for Windows which uses the default paths. /// [SupportedOSPlatform("windows")] public class WindowsVelopackLocator : VelopackLocator diff --git a/src/Velopack/NuGet/NuspecManifest.cs b/src/Velopack/NuGet/NuspecManifest.cs index 61aaea11..e18578da 100644 --- a/src/Velopack/NuGet/NuspecManifest.cs +++ b/src/Velopack/NuGet/NuspecManifest.cs @@ -185,7 +185,7 @@ namespace Velopack.NuGet break; // === - // the following metadata elements are added by squirrel and are not + // the following metadata elements are added by velopack and are not // used by nuget. case "runtimeDependencies": RuntimeDependencies = getCommaDelimitedValue(value); diff --git a/src/Velopack/ReleaseEntry.cs b/src/Velopack/ReleaseEntry.cs index 8f8725fd..e8548be0 100644 --- a/src/Velopack/ReleaseEntry.cs +++ b/src/Velopack/ReleaseEntry.cs @@ -25,7 +25,7 @@ namespace Velopack } /// - /// Represents a Squirrel release, as described in a RELEASES file - usually also with an + /// Represents a Velopack release, as described in a RELEASES file - usually also with an /// accompanying package containing the files needed to apply the release. /// [DataContract] diff --git a/src/Velopack/Sources/GithubSource.cs b/src/Velopack/Sources/GithubSource.cs index 753e4b1f..23720868 100644 --- a/src/Velopack/Sources/GithubSource.cs +++ b/src/Velopack/Sources/GithubSource.cs @@ -146,7 +146,7 @@ namespace Velopack.Sources if (releases == null || releases.Count() == 0) throw new Exception($"No GitHub releases found at '{RepoUri}'."); - // for now, we only search for Squirrel packages in the latest Github release. + // for now, we only search for packages in the latest Github release. // in the future, we might want to search through more than one for delta's. var release = releases.First(); diff --git a/src/Velopack/Sources/GitlabSource.cs b/src/Velopack/Sources/GitlabSource.cs index d2e05430..672e3176 100644 --- a/src/Velopack/Sources/GitlabSource.cs +++ b/src/Velopack/Sources/GitlabSource.cs @@ -191,7 +191,7 @@ namespace Velopack.Sources if (releases == null || releases.Count() == 0) throw new Exception($"No Gitlab releases found at '{RepoUri}'."); - // for now, we only search for Squirrel packages in the latest Github release. + // for now, we only search for packages in the latest Github release. // in the future, we might want to search through more than one for delta's. var release = releases.First(); diff --git a/src/Velopack/Sources/HttpClientFileDownloader.cs b/src/Velopack/Sources/HttpClientFileDownloader.cs index 76491dc5..7a841f47 100644 --- a/src/Velopack/Sources/HttpClientFileDownloader.cs +++ b/src/Velopack/Sources/HttpClientFileDownloader.cs @@ -13,9 +13,9 @@ namespace Velopack.Sources public class HttpClientFileDownloader : IFileDownloader { /// - /// The User-Agent sent with Squirrel requests + /// The User-Agent sent with requests /// - public static ProductInfoHeaderValue UserAgent => new("Squirrel", VelopackRuntimeInfo.SquirrelNugetVersion.ToFullString()); + public static ProductInfoHeaderValue UserAgent => new("Velopack", VelopackRuntimeInfo.VelopackNugetVersion.ToFullString()); /// public virtual async Task DownloadFile(string url, string targetFile, Action progress, string authorization, string accept) diff --git a/src/Velopack/UpdateManager.cs b/src/Velopack/UpdateManager.cs index a7728fae..95d4f5de 100644 --- a/src/Velopack/UpdateManager.cs +++ b/src/Velopack/UpdateManager.cs @@ -19,7 +19,7 @@ namespace Velopack /// public class UpdateManager { - /// The currently installed Squirrel application Id. This would be what you set when you create your Squirrel release. + /// The currently installed application Id. This would be what you set when you create your release. public virtual string AppId => Locator.AppId; /// True if this application is currently installed, and is able to download/check for updates. @@ -36,7 +36,7 @@ namespace Velopack } } - /// The currently installed Squirrel app version when you created your release. Null if this is not a currently installed app. + /// The currently installed app version when you created your release. Null if this is not a currently installed app. public virtual SemanticVersion CurrentVersion => Locator.CurrentlyInstalledVersion; /// The update source to use when checking for/downloading updates. diff --git a/src/Velopack/VelopackApp.cs b/src/Velopack/VelopackApp.cs index 5b0d8de6..742d50a9 100644 --- a/src/Velopack/VelopackApp.cs +++ b/src/Velopack/VelopackApp.cs @@ -40,12 +40,12 @@ namespace Velopack } /// - /// Creates and returns a new Squirrel application builder. + /// Creates and returns a new Velopack application builder. /// public static VelopackApp Build() => new VelopackApp(); /// - /// Override the command line arguments used to determine the Squirrel hook to run. + /// Override the command line arguments used to determine the Velopack hook to run. /// If this is not set, the command line arguments passed to the application will be used. /// public VelopackApp SetArgs(string[] args) @@ -82,7 +82,7 @@ namespace Velopack } /// - /// This hook is triggered when the application is restarted by Squirrel after installing updates. + /// This hook is triggered when the application is restarted by Velopack after installing updates. /// public VelopackApp WithRestarted(VelopackHook hook) { @@ -91,7 +91,7 @@ namespace Velopack } /// - /// WARNING: FastCallback hooks are run during critical stages of Squirrel operations. + /// WARNING: FastCallback hooks are run during critical stages of Velopack operations. /// Your code will be run and then will be called. /// If your code has not completed within 30 seconds, it will be terminated. /// Only supported on windows; On other operating systems, this will never be called. @@ -104,7 +104,7 @@ namespace Velopack } /// - /// WARNING: FastCallback hooks are run during critical stages of Squirrel operations. + /// WARNING: FastCallback hooks are run during critical stages of Velopack operations. /// Your code will be run and then will be called. /// If your code has not completed within 15 seconds, it will be terminated. /// Only supported on windows; On other operating systems, this will never be called. @@ -117,7 +117,7 @@ namespace Velopack } /// - /// WARNING: FastCallback hooks are run during critical stages of Squirrel operations. + /// WARNING: FastCallback hooks are run during critical stages of Velopack operations. /// Your code will be run and then will be called. /// If your code has not completed within 15 seconds, it will be terminated. /// Only supported on windows; On other operating systems, this will never be called. @@ -130,7 +130,7 @@ namespace Velopack } /// - /// WARNING: FastCallback hooks are run during critical stages of Squirrel operations. + /// WARNING: FastCallback hooks are run during critical stages of Velopack operations. /// Your code will be run and then will be called. /// If your code has not completed within 30 seconds, it will be terminated. /// Only supported on windows; On other operating systems, this will never be called. @@ -143,7 +143,7 @@ namespace Velopack } /// - /// Runs the Squirrel application startup code and triggers any configured hooks. + /// Runs the Velopack application startup code and triggers any configured hooks. /// /// A logging interface for diagnostic messages. public void Run(ILogger logger = null) @@ -152,22 +152,22 @@ namespace Velopack var log = logger ?? NullLogger.Instance; var locator = _locator ?? VelopackLocator.GetDefault(log); - // internal hook run by the Squirrel tooling to check everything is working - if (args.Length >= 1 && args[0].Equals("--squirrel-version", StringComparison.OrdinalIgnoreCase)) { - Console.WriteLine(VelopackRuntimeInfo.SquirrelNugetVersion); + // internal hook run by the Velopack tooling to check everything is working + if (args.Length >= 1 && args[0].Equals("--Velopack-version", StringComparison.OrdinalIgnoreCase)) { + Console.WriteLine(VelopackRuntimeInfo.VelopackNugetVersion); Exit(0); return; } - log.Info("Starting Squirrel App (Run)."); + log.Info("Starting Velopack App (Run)."); // first, we run any fast exit hooks VelopackHook defaultBlock = ((v) => { }); var fastExitlookup = new[] { - new { Key = "--squirrel-install", Value = _install ?? defaultBlock }, - new { Key = "--squirrel-updated", Value = _update ?? defaultBlock }, - new { Key = "--squirrel-obsolete", Value = _obsolete ?? defaultBlock }, - new { Key = "--squirrel-uninstall", Value = _uninstall ?? defaultBlock }, + new { Key = "--Velopack-install", Value = _install ?? defaultBlock }, + new { Key = "--Velopack-updated", Value = _update ?? defaultBlock }, + new { Key = "--Velopack-obsolete", Value = _obsolete ?? defaultBlock }, + new { Key = "--Velopack-uninstall", Value = _uninstall ?? defaultBlock }, }.ToDictionary(k => k.Key, v => v.Value, StringComparer.OrdinalIgnoreCase); if (args.Length >= 2 && fastExitlookup.ContainsKey(args[0])) { try { @@ -178,7 +178,7 @@ namespace Velopack Exit(0); return; } catch (Exception ex) { - log.Error(ex, $"Error occurred executing user defined Squirrel hook. ({args[0]})"); + log.Error(ex, $"Error occurred executing user defined Velopack hook. ({args[0]})"); Exit(-1); return; } @@ -186,12 +186,12 @@ namespace Velopack // some initial setup/state var myVersion = locator.CurrentlyInstalledVersion; - var firstrun = !String.IsNullOrWhiteSpace(Environment.GetEnvironmentVariable("CLOWD_SQUIRREL_FIRSTRUN")); - var restarted = !String.IsNullOrWhiteSpace(Environment.GetEnvironmentVariable("CLOWD_SQUIRREL_RESTART")); + var firstrun = !String.IsNullOrWhiteSpace(Environment.GetEnvironmentVariable("CLOWD_Velopack_FIRSTRUN")); + var restarted = !String.IsNullOrWhiteSpace(Environment.GetEnvironmentVariable("CLOWD_Velopack_RESTART")); var localPackages = locator.GetLocalPackages(); var latestLocal = locator.GetLatestLocalFullPackage(); - // if we've not just been restarted via Squirrel apply, and there is a local update available, + // if we've not just been restarted via Velopack apply, and there is a local update available, // we should install it first. if (latestLocal != null && latestLocal.Version > myVersion) { log.Info($"Launching app is out-dated. Current: {myVersion}, Newest Local Available: {latestLocal.Version}"); @@ -222,14 +222,14 @@ namespace Velopack try { _firstrun(myVersion); } catch (Exception ex) { - log.Error(ex, $"Error occurred executing user defined Squirrel hook. (firstrun)"); + log.Error(ex, $"Error occurred executing user defined Velopack hook. (firstrun)"); } } if (restarted) { try { _restarted(myVersion); } catch (Exception ex) { - log.Error(ex, $"Error occurred executing user defined Squirrel hook. (restarted)"); + log.Error(ex, $"Error occurred executing user defined Velopack hook. (restarted)"); } } } diff --git a/src/Velopack/VelopackRuntimeInfo.cs b/src/Velopack/VelopackRuntimeInfo.cs index 07406591..ca737488 100644 --- a/src/Velopack/VelopackRuntimeInfo.cs +++ b/src/Velopack/VelopackRuntimeInfo.cs @@ -79,14 +79,14 @@ namespace Velopack /// public static class VelopackRuntimeInfo { - /// The current compiled Squirrel display version. - public static string SquirrelDisplayVersion { get; } + /// The current compiled Velopack display version. + public static string VelopackDisplayVersion { get; } - /// The current compiled Squirrel NuGetVersion. - public static NuGetVersion SquirrelNugetVersion { get; } + /// The current compiled Velopack NuGetVersion. + public static NuGetVersion VelopackNugetVersion { get; } - /// The current compiled Squirrel assembly file version. - public static string SquirrelFileVersion => ThisAssembly.AssemblyFileVersion; + /// The current compiled Velopack assembly file version. + public static string VelopackFileVersion => ThisAssembly.AssemblyFileVersion; /// The path on disk of the entry assembly. public static string EntryExePath { get; } @@ -145,11 +145,11 @@ namespace Velopack IsSingleFile = true; // get git/nuget version from nbgv metadata - SquirrelNugetVersion = NuGetVersion.Parse(ThisAssembly.AssemblyInformationalVersion); - if (SquirrelNugetVersion.HasMetadata) { - SquirrelNugetVersion = NuGetVersion.Parse(SquirrelNugetVersion.ToNormalizedString() + "-g" + SquirrelNugetVersion.Metadata); + VelopackNugetVersion = NuGetVersion.Parse(ThisAssembly.AssemblyInformationalVersion); + if (VelopackNugetVersion.HasMetadata) { + VelopackNugetVersion = NuGetVersion.Parse(VelopackNugetVersion.ToNormalizedString() + "-g" + VelopackNugetVersion.Metadata); } - SquirrelDisplayVersion = SquirrelNugetVersion.ToNormalizedString() + (SquirrelNugetVersion.IsPrerelease ? " (prerelease)" : ""); + VelopackDisplayVersion = VelopackNugetVersion.ToNormalizedString() + (VelopackNugetVersion.IsPrerelease ? " (prerelease)" : ""); // get real cpu architecture, even when virtualised by Wow64 #if NETFRAMEWORK diff --git a/src/Velopack/Windows/RuntimeInfo.cs b/src/Velopack/Windows/RuntimeInfo.cs index 539f6194..39aa5384 100644 --- a/src/Velopack/Windows/RuntimeInfo.cs +++ b/src/Velopack/Windows/RuntimeInfo.cs @@ -174,7 +174,7 @@ namespace Velopack.Windows public NuGetVersion MinVersion { get; } /// The CPU architecture of the runtime. This must match the RID of the app being deployed. - /// For example, if the Squirrel app was deployed with 'win-x64', this must be X64 also. + /// For example, if the app was deployed with 'win-x64', this must be X64 also. public RuntimeCpu CpuArchitecture { get; } /// The type of runtime required, eg. Windows Desktop, AspNetCore, Sdk. diff --git a/test/Velopack.Packaging.Tests/Init.cs b/test/Velopack.Packaging.Tests/Init.cs index 99417436..18408dd2 100644 --- a/test/Velopack.Packaging.Tests/Init.cs +++ b/test/Velopack.Packaging.Tests/Init.cs @@ -4,7 +4,7 @@ using Velopack.Packaging; using Xunit.Abstractions; using Xunit.Sdk; -[assembly: TestFramework("Squirrel.Packaging.Tests.TestsInit", "Squirrel.Packaging.Tests")] +[assembly: TestFramework("Velopack.Packaging.Tests.TestsInit", "Velopack.Packaging.Tests")] namespace Velopack.Packaging.Tests { diff --git a/test/Velopack.Tests/UpdateManager/ApplyReleasesTests.cs b/test/Velopack.Tests/UpdateManager/ApplyReleasesTests.cs deleted file mode 100644 index 3f38e382..00000000 --- a/test/Velopack.Tests/UpdateManager/ApplyReleasesTests.cs +++ /dev/null @@ -1,527 +0,0 @@ -//using System; -//using System.Collections.Generic; -//using System.Diagnostics; -//using System.IO; -//using System.Linq; -//using System.Reflection; -//using System.Text; -//using System.Threading; -//using System.Threading.Tasks; -//using NuGet.Versioning; -//using Squirrel.NuGet; -//using Squirrel.Tests.TestHelpers; -//using Xunit; -//using Xunit.Abstractions; - -//namespace Squirrel.Tests -//{ -// public class ApplyReleasesTests : TestLoggingBase -// { -// public ApplyReleasesTests(ITestOutputHelper log) : base(log) -// { -// } - -// public const string APP_ID = "theFakeApp"; - -// [Fact] -// public async Task CleanInstallRunsSquirrelAwareAppsWithInstallFlag() -// { -// using var _1 = Utility.GetTempDirectory(out var tempDir); -// using var _2 = Utility.GetTempDirectory(out var remotePkgDir); - -// IntegrationTestHelper.CreateNewVersionInPackageDir("0.1.0", remotePkgDir); -// using var fixture = UpdateManagerTestImpl.FromLocalPackageTempDir(remotePkgDir, APP_ID, tempDir); -// await fixture.FullInstall(); - -// // NB: We execute the Squirrel-aware apps, so we need to give -// // them a minute to settle or else the using statement will -// // try to blow away a running process -// await Task.Delay(1000); - -// Assert.False(File.Exists(Path.Combine(tempDir, APP_ID, "current", "args2.txt"))); -// Assert.True(File.Exists(Path.Combine(tempDir, APP_ID, "current", "args.txt"))); - -// var text = File.ReadAllText(Path.Combine(tempDir, APP_ID, "current", "args.txt"), Encoding.UTF8); -// Assert.Contains("firstrun", text); -// } - -// [Fact] -// public async Task UpgradeRunsSquirrelAwareAppsWithUpgradeFlag() -// { -// using var _1 = Utility.GetTempDirectory(out var tempDir); -// using var _2 = Utility.GetTempDirectory(out var remotePkgDir); - -// IntegrationTestHelper.CreateNewVersionInPackageDir("0.1.0", remotePkgDir); - -// using (var fixture = UpdateManagerTestImpl.FromLocalPackageTempDir(remotePkgDir, APP_ID, tempDir)) { -// await fixture.FullInstall(); -// } - -// await Task.Delay(1000); - -// IntegrationTestHelper.CreateNewVersionInPackageDir("0.2.0", remotePkgDir); - -// using (var fixture = UpdateManagerTestImpl.FromLocalPackageTempDir(remotePkgDir, APP_ID, tempDir)) { -// await fixture.UpdateApp(); -// } - -// await Task.Delay(1000); - -// Assert.False(File.Exists(Path.Combine(tempDir, APP_ID, "staging", "app-0.2.0", "args2.txt"))); -// Assert.True(File.Exists(Path.Combine(tempDir, APP_ID, "staging", "app-0.2.0", "args.txt"))); - -// var text = File.ReadAllText(Path.Combine(tempDir, APP_ID, "staging", "app-0.2.0", "args.txt"), Encoding.UTF8); -// Assert.Contains("updated", text); -// Assert.Contains("0.2.0", text); -// } - -// [Fact] -// public async Task RunningUpgradeAppTwiceDoesntCrash() -// { -// using var _1 = Utility.GetTempDirectory(out var tempDir); -// using var _2 = Utility.GetTempDirectory(out var remotePkgDir); - -// IntegrationTestHelper.CreateNewVersionInPackageDir("0.1.0", remotePkgDir); - -// using (var fixture = UpdateManagerTestImpl.FromLocalPackageTempDir(remotePkgDir, APP_ID, tempDir)) { -// await fixture.FullInstall(); -// } - -// await Task.Delay(1000); - -// IntegrationTestHelper.CreateNewVersionInPackageDir("0.2.0", remotePkgDir); - -// using (var fixture = UpdateManagerTestImpl.FromLocalPackageTempDir(remotePkgDir, APP_ID, tempDir)) { -// await fixture.UpdateApp(); -// } - -// await Task.Delay(1000); - -// // NB: The 2nd time we won't have any updates to apply. We should just do nothing! -// using (var fixture = UpdateManagerTestImpl.FromLocalPackageTempDir(remotePkgDir, APP_ID, tempDir)) { -// await fixture.UpdateApp(); -// } - -// await Task.Delay(1000); -// } - -// [Fact] -// public async Task FullUninstallRemovesAllVersions() -// { -// using var _1 = Utility.GetTempDirectory(out var tempDir); -// using var _2 = Utility.GetTempDirectory(out var remotePkgDir); - -// IntegrationTestHelper.CreateNewVersionInPackageDir("0.1.0", remotePkgDir); - -// using (var fixture = UpdateManagerTestImpl.FromLocalPackageTempDir(remotePkgDir, APP_ID, tempDir)) { -// await fixture.FullInstall(); -// } - -// await Task.Delay(1000); - -// IntegrationTestHelper.CreateNewVersionInPackageDir("0.2.0", remotePkgDir); - -// using (var fixture = UpdateManagerTestImpl.FromLocalPackageTempDir(remotePkgDir, APP_ID, tempDir)) { -// await fixture.UpdateApp(); -// } - -// await Task.Delay(1000); - -// using (var fixture = UpdateManagerTestImpl.FromLocalPackageTempDir(remotePkgDir, APP_ID, tempDir)) { -// await fixture.FullUninstall(); -// } - -// Assert.False(File.Exists(Path.Combine(tempDir, APP_ID, "app-0.1.0", "args.txt"))); -// Assert.False(File.Exists(Path.Combine(tempDir, APP_ID, "app-0.2.0", "args.txt"))); -// Assert.True(File.Exists(Path.Combine(tempDir, APP_ID, ".dead"))); -// } - -// [Fact] -// public async Task CanInstallAndUpdatePackageWithDotsInId() -// { -// string tempDir; -// string remotePkgDir; -// const string pkgName = "Squirrel.Installed.App"; - -// using (Utility.GetTempDirectory(out tempDir)) -// using (Utility.GetTempDirectory(out remotePkgDir)) { -// // install 0.1.0 -// IntegrationTestHelper.CreateFakeInstalledApp("0.1.0", remotePkgDir, "SquirrelInstalledAppWithDots.nuspec"); -// var pkgs = ReleaseEntry.BuildReleasesFile(remotePkgDir); -// ReleaseEntry.WriteReleaseFile(pkgs, Path.Combine(remotePkgDir, "RELEASES")); - -// using (var fixture = UpdateManagerTestImpl.FromLocalPackageTempDir(remotePkgDir, pkgName, tempDir)) { -// await fixture.FullInstall(); -// } - -// //Assert.True(Directory.Exists(Path.Combine(tempDir, pkgName, "app-0.1.0"))); -// Assert.True(Directory.Exists(Path.Combine(tempDir, pkgName, "current"))); - -// var info = new AppDescWindows(Path.Combine(tempDir, pkgName), pkgName); - -// var version = info.GetVersions().Single(); -// Assert.True(version.IsCurrent); -// Assert.Equal(new SemanticVersion(0, 1, 0), version.Manifest.Version); - -// await Task.Delay(1000); -// Assert.True(File.ReadAllText(Path.Combine(version.DirectoryPath, "args.txt")).Contains("--squirrel-firstrun")); - -// // update top 0.2.0 -// IntegrationTestHelper.CreateFakeInstalledApp("0.2.0", remotePkgDir, "SquirrelInstalledAppWithDots.nuspec"); -// pkgs = ReleaseEntry.BuildReleasesFile(remotePkgDir); -// ReleaseEntry.WriteReleaseFile(pkgs, Path.Combine(remotePkgDir, "RELEASES")); - -// using (var fixture = UpdateManagerTestImpl.FromLocalPackageTempDir(remotePkgDir, pkgName, tempDir)) { -// await fixture.UpdateApp(); -// } - -// info.UpdateAndRetrieveCurrentFolder(false); - -// var versions = info.GetVersions().ToArray(); -// Assert.Equal(2, versions.Count()); -// Assert.Equal(new SemanticVersion(0, 2, 0), versions.Single(s => s.IsCurrent).Version); - -// //Assert.True(Directory.Exists(Path.Combine(tempDir, pkgName, "app-0.2.0"))); -// await Task.Delay(1000); - -// // uninstall -// using (var fixture = UpdateManagerTestImpl.FromLocalPackageTempDir(remotePkgDir, pkgName, tempDir)) { -// await fixture.FullUninstall(); -// } - -// Assert.False(File.Exists(Path.Combine(tempDir, pkgName, "app-0.1.0", "args.txt"))); -// Assert.False(File.Exists(Path.Combine(tempDir, pkgName, "app-0.2.0", "args.txt"))); -// Assert.True(File.Exists(Path.Combine(tempDir, pkgName, ".dead"))); -// } -// } - -// [Fact] -// public void WhenNoNewReleasesAreAvailableTheListIsEmpty() -// { -// using var _ = Utility.GetTempDirectory(out var tempDir); - -// var appDir = Directory.CreateDirectory(Path.Combine(tempDir, APP_ID)); -// var packages = Path.Combine(appDir.FullName, "packages"); -// Directory.CreateDirectory(packages); - -// var package = "Squirrel.Core.1.0.0.0-full.nupkg"; -// File.Copy(IntegrationTestHelper.GetPath("fixtures", package), Path.Combine(packages, package)); - -// var aGivenPackage = Path.Combine(packages, package); -// var baseEntry = ReleaseEntry.GenerateFromFile(aGivenPackage); - -// var updateInfo = UpdateInfo.Create(baseEntry, new[] { baseEntry }, "dontcare"); - -// Assert.Empty(updateInfo.ReleasesToApply); -// } - -// [Fact] -// public void ThrowsWhenOnlyDeltaReleasesAreAvailable() -// { -// string tempDir; -// using (Utility.GetTempDirectory(out tempDir)) { -// var appDir = Directory.CreateDirectory(Path.Combine(tempDir, APP_ID)); -// var packages = Path.Combine(appDir.FullName, "packages"); -// Directory.CreateDirectory(packages); - -// var baseFile = "Squirrel.Core.1.0.0.0-full.nupkg"; -// File.Copy(IntegrationTestHelper.GetPath("fixtures", baseFile), -// Path.Combine(packages, baseFile)); -// var basePackage = Path.Combine(packages, baseFile); -// var baseEntry = ReleaseEntry.GenerateFromFile(basePackage); - -// var deltaFile = "Squirrel.Core.1.1.0.0-delta.nupkg"; -// File.Copy(IntegrationTestHelper.GetPath("fixtures", deltaFile), -// Path.Combine(packages, deltaFile)); -// var deltaPackage = Path.Combine(packages, deltaFile); -// var deltaEntry = ReleaseEntry.GenerateFromFile(deltaPackage); - -// Assert.Throws( -// () => UpdateInfo.Create(baseEntry, new[] { deltaEntry }, "dontcare")); -// } -// } - -// [Fact] -// public async Task ApplyReleasesWithOneReleaseFile() -// { -// string tempDir; - -// using (Utility.GetTempDirectory(out tempDir)) { -// string appDir = Path.Combine(tempDir, APP_ID); -// string packagesDir = Path.Combine(appDir, "packages"); -// Directory.CreateDirectory(packagesDir); - -// new[] { -// "Squirrel.Core.1.0.0.0-full.nupkg", -// "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("", 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")); - -// var updateInfo = UpdateInfo.Create(baseEntry, new[] { latestFullEntry }, packagesDir); -// updateInfo.ReleasesToApply.Contains(latestFullEntry).ShouldBeTrue(); - -// var progress = new List(); - -// await fixture.ApplyReleasesPublic(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 filesToFind = new[] { -// new { Name = "NLog.dll", Version = new Version("2.0.0.0") }, -// new { Name = "NSync.Core.dll", Version = new Version("1.1.0.0") }, -// }; - -// filesToFind.ForEach(x => { -// var path = Path.Combine(tempDir, APP_ID, "staging", "app-1.1.0.0", x.Name); -// this.Log().Info("Looking for {0}", path); -// File.Exists(path).ShouldBeTrue(); - -// var vi = FileVersionInfo.GetVersionInfo(path); -// var verInfo = new Version(vi.FileVersion ?? "1.0.0.0"); -// x.Version.ShouldEqual(verInfo); -// }); -// } -// } - -// [Fact] -// public async Task ApplyReleaseWhichRemovesAFile() -// { -// string tempDir; - -// using (Utility.GetTempDirectory(out tempDir)) { -// string appDir = Path.Combine(tempDir, APP_ID); -// 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))); - -// 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")); - -// var updateInfo = UpdateInfo.Create(baseEntry, new[] { latestFullEntry }, packagesDir); -// updateInfo.ReleasesToApply.Contains(latestFullEntry).ShouldBeTrue(); - -// var progress = new List(); -// await fixture.ApplyReleasesPublic(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, APP_ID, "staging", "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(); -// } -// } - -// [Fact] -// public async Task ApplyReleaseWhichMovesAFileToADifferentDirectory() -// { -// string tempDir; - -// using (Utility.GetTempDirectory(out tempDir)) { -// string appDir = Path.Combine(tempDir, APP_ID); -// string packagesDir = Path.Combine(appDir, "packages"); -// Directory.CreateDirectory(packagesDir); - -// new[] { -// "Squirrel.Core.1.1.0.0-full.nupkg", -// "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("", 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")); - -// var updateInfo = UpdateInfo.Create(baseEntry, new[] { latestFullEntry }, packagesDir); -// updateInfo.ReleasesToApply.Contains(latestFullEntry).ShouldBeTrue(); - -// var progress = new List(); -// await fixture.ApplyReleasesPublic(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, APP_ID, "staging", "app-1.3.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 oldFile = Path.Combine(rootDirectory, "sub", "Ionic.Zip.dll"); -// File.Exists(oldFile).ShouldBeFalse(); - -// var newFile = Path.Combine(rootDirectory, "other", "Ionic.Zip.dll"); -// File.Exists(newFile).ShouldBeTrue(); -// } -// } - -// [Fact] -// public async Task ApplyReleasesWithDeltaReleases() -// { -// string tempDir; - -// using (Utility.GetTempDirectory(out tempDir)) { -// string appDir = Path.Combine(tempDir, APP_ID); -// string packagesDir = Path.Combine(appDir, "packages"); -// Directory.CreateDirectory(packagesDir); - -// 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 => File.Copy(IntegrationTestHelper.GetPath("fixtures", x), Path.Combine(packagesDir, x))); - -// 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")); -// var latestFullEntry = ReleaseEntry.GenerateFromFile(Path.Combine(packagesDir, "Squirrel.Core.1.1.0.0-full.nupkg")); - -// var updateInfo = UpdateInfo.Create(baseEntry, new[] { deltaEntry, latestFullEntry }, packagesDir); -// updateInfo.ReleasesToApply.Contains(deltaEntry).ShouldBeTrue(); - -// var progress = new List(); - -// await fixture.ApplyReleasesPublic(updateInfo, false, false, progress.Add); -// this.Log().Info("Progress: [{0}]", String.Join(",", progress)); - -// // TODO: this is failing intermittently, not sure why but is not a big deal atm -// // progress -// // .Aggregate(0, (acc, x) => { (x >= acc).ShouldBeTrue(); return x; }) -// // .ShouldEqual(100); - -// var filesToFind = new[] { -// new { Name = "NLog.dll", Version = new Version("2.0.0.0") }, -// new { Name = "NSync.Core.dll", Version = new Version("1.1.0.0") }, -// }; - -// filesToFind.ForEach(x => { -// var path = Path.Combine(tempDir, APP_ID, "staging", "app-1.1.0.0", x.Name); -// this.Log().Info("Looking for {0}", path); -// File.Exists(path).ShouldBeTrue(); - -// var vi = FileVersionInfo.GetVersionInfo(path); -// var verInfo = new Version(vi.FileVersion ?? "1.0.0.0"); -// x.Version.ShouldEqual(verInfo); -// }); -// } -// } - -// [Fact] -// public async Task CreateFullPackagesFromDeltaSmokeTest() -// { -// string tempDir; -// using (Utility.GetTempDirectory(out tempDir)) { -// string appDir = Path.Combine(tempDir, APP_ID); -// string packagesDir = Path.Combine(appDir, "packages"); -// Directory.CreateDirectory(packagesDir); - -// new[] { -// "Squirrel.Core.1.0.0.0-full.nupkg", -// "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("", 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")); - -// var result = fixture.createFullPackagesFromDeltas(new[] { deltaEntry }, baseEntry, null); - -// var zp = new ZipPackage(Path.Combine(tempDir, APP_ID, "packages", result.Filename)); -// zp.Version.ToString().ShouldEqual("1.1.0.0"); -// } -// } - -// [Fact] -// public async Task CreateShortcutsRoundTrip() -// { -// using var _1 = Utility.GetTempDirectory(out var tempDir); -// using var _2 = Utility.GetTempDirectory(out var remotePkgDir); - -// IntegrationTestHelper.CreateNewVersionInPackageDir("0.1.0", remotePkgDir); -// using var fixture = UpdateManagerTestImpl.FromLocalPackageTempDir(remotePkgDir, APP_ID, tempDir); -// await fixture.FullInstall(); - -// fixture.CreateShortcutsForExecutable("SquirrelAwareApp.exe", -// ShortcutLocation.Desktop | ShortcutLocation.StartMenu | ShortcutLocation.Startup | ShortcutLocation.AppRoot, false, null, null); - -// Assert.True(File.Exists(Path.Combine(tempDir, APP_ID, "PublishSingleFileAwareApp.lnk"))); - -// // 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); -// } - -// //[Fact] -// //public async Task GetShortcutsSmokeTest() -// //{ -// // string remotePkgPath; -// // string path; - -// // using (Utility.WithTempDirectory(out path)) { -// // using (Utility.WithTempDirectory(out remotePkgPath)) -// // using (var mgr = new UpdateManager(remotePkgPath, APP_ID, path)) { -// // IntegrationTestHelper.CreateFakeInstalledApp("1.0.0.1", remotePkgPath); -// // await mgr.FullInstall(); -// // } - -// // var fixture = new ApplyReleasesImpl(Path.Combine(path, APP_ID)); -// // 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); -// // } -// //} -// } -//} \ No newline at end of file diff --git a/test/Velopack.Tests/UpdateManager/CheckForUpdateTests.cs b/test/Velopack.Tests/UpdateManager/CheckForUpdateTests.cs deleted file mode 100644 index 69f02bf0..00000000 --- a/test/Velopack.Tests/UpdateManager/CheckForUpdateTests.cs +++ /dev/null @@ -1,178 +0,0 @@ -//using System; -//using System.IO; -//using System.Linq; -//using System.Text; -//using System.Threading.Tasks; -//using System.Web; -//using Squirrel.Tests.TestHelpers; -//using Xunit; - -//namespace Squirrel.Tests -//{ -// public class CheckForUpdateTests -// { -// [Fact(Skip = "Rewrite this to be an integration test")] -// public void NewReleasesShouldBeDetected() -// { -// Assert.Fail("Rewrite this to be an integration test"); -// /* -// string localReleasesFile = Path.Combine(".", "theApp", "packages", "RELEASES"); - -// var fileInfo = new Mock(); -// fileInfo.Setup(x => x.OpenRead()) -// .Returns(File.OpenRead(IntegrationTestHelper.GetPath("fixtures", "RELEASES-OnePointOh"))); - -// var fs = new Mock(); -// fs.Setup(x => x.GetFileInfo(localReleasesFile)).Returns(fileInfo.Object); - -// var urlDownloader = new Mock(); -// var dlPath = IntegrationTestHelper.GetPath("fixtures", "RELEASES-OnePointOne"); -// urlDownloader.Setup(x => x.DownloadUrl(It.IsAny(), It.IsAny>())) -// .Returns(Observable.Return(File.ReadAllText(dlPath, Encoding.UTF8))); - -// var fixture = new UpdateManager("http://lol", "theApp", ".", fs.Object, urlDownloader.Object); -// var result = default(UpdateInfo); - -// using (fixture) { -// result = fixture.CheckForUpdate().First(); -// } - -// Assert.NotNull(result); -// Assert.Equal(1, result.ReleasesToApply.Single().Version.Major); -// Assert.Equal(1, result.ReleasesToApply.Single().Version.Minor); -// */ -// } - -// [Fact(Skip = "Rewrite this to be an integration test")] -// public void CorruptedReleaseFileMeansWeStartFromScratch() -// { -// Assert.Fail("Rewrite this to be an integration test"); - -// /* -// string localPackagesDir = Path.Combine(".", "theApp", "packages"); -// string localReleasesFile = Path.Combine(localPackagesDir, "RELEASES"); - -// var fileInfo = new Mock(); -// fileInfo.Setup(x => x.Exists).Returns(true); -// fileInfo.Setup(x => x.OpenRead()) -// .Returns(new MemoryStream(Encoding.UTF8.GetBytes("lol this isn't right"))); - -// var dirInfo = new Mock(); -// dirInfo.Setup(x => x.Exists).Returns(true); - -// var fs = new Mock(); -// fs.Setup(x => x.GetFileInfo(localReleasesFile)).Returns(fileInfo.Object); -// fs.Setup(x => x.CreateDirectoryRecursive(localPackagesDir)).Verifiable(); -// fs.Setup(x => x.DeleteDirectoryRecursive(localPackagesDir)).Verifiable(); -// fs.Setup(x => x.GetDirectoryInfo(localPackagesDir)).Returns(dirInfo.Object); - -// var urlDownloader = new Mock(); -// var dlPath = IntegrationTestHelper.GetPath("fixtures", "RELEASES-OnePointOne"); -// urlDownloader.Setup(x => x.DownloadUrl(It.IsAny(), It.IsAny>())) -// .Returns(Observable.Return(File.ReadAllText(dlPath, Encoding.UTF8))); - -// var fixture = new UpdateManager("http://lol", "theApp", ".", fs.Object, urlDownloader.Object); -// using (fixture) { -// fixture.CheckForUpdate().First(); -// } - -// fs.Verify(x => x.CreateDirectoryRecursive(localPackagesDir), Times.Once()); -// fs.Verify(x => x.DeleteDirectoryRecursive(localPackagesDir), Times.Once()); -// */ -// } - -// [Fact(Skip = "Rewrite this to be an integration test")] -// public void CorruptRemoteFileShouldThrowOnCheck() -// { -// Assert.Fail("Rewrite this to be an integration test"); - -// /* -// string localPackagesDir = Path.Combine(".", "theApp", "packages"); -// string localReleasesFile = Path.Combine(localPackagesDir, "RELEASES"); - -// var fileInfo = new Mock(); -// fileInfo.Setup(x => x.Exists).Returns(false); - -// var dirInfo = new Mock(); -// dirInfo.Setup(x => x.Exists).Returns(true); - -// var fs = new Mock(); -// fs.Setup(x => x.GetFileInfo(localReleasesFile)).Returns(fileInfo.Object); -// fs.Setup(x => x.CreateDirectoryRecursive(localPackagesDir)).Verifiable(); -// fs.Setup(x => x.DeleteDirectoryRecursive(localPackagesDir)).Verifiable(); -// fs.Setup(x => x.GetDirectoryInfo(localPackagesDir)).Returns(dirInfo.Object); - -// var urlDownloader = new Mock(); -// urlDownloader.Setup(x => x.DownloadUrl(It.IsAny(), It.IsAny>())) -// .Returns(Observable.Return("lol this isn't right")); - -// var fixture = new UpdateManager("http://lol", "theApp", ".", fs.Object, urlDownloader.Object); - -// using (fixture) { -// Assert.Throws(() => fixture.CheckForUpdate().First()); -// } -// */ -// } - -// [Fact(Skip = "TODO")] -// public void IfLocalVersionGreaterThanRemoteWeRollback() -// { -// throw new NotImplementedException(); -// } - -// [Fact(Skip = "TODO")] -// public void IfLocalAndRemoteAreEqualThenDoNothing() -// { -// throw new NotImplementedException(); -// } - -// [Theory] -// [InlineData(@"94689fede03fed7ab59c24337673a27837f0c3ec MyCoolApp-1.0.nupkg 1004502", "MyCoolApp", null)] -// [InlineData(@"0000000000000000000000000000000000000000 https://www.test.org/Folder/MyCoolApp-1.2-delta.nupkg?query=param 1231953", "MyCoolApp", "https://www.test.org/Folder")] -// public async Task WebSourceRequestsExpectedUrls(string releaseEntry, string releaseName, string baseUrl) -// { -// baseUrl = baseUrl ?? "https://example.com/files"; -// var dl = new FakeDownloader(); -// var source = new Sources.SimpleWebSource("https://example.com/files", dl); - -// dl.MockedResponseBytes = Encoding.UTF8.GetBytes(releaseEntry); -// var releases = await source.GetReleaseFeed(null, null); -// Assert.True(releases.Count() == 1); -// Assert.Equal(releaseName, releases[0].PackageName); -// Assert.Equal("https://example.com/files/RELEASES", new Uri(dl.LastUrl).GetLeftPart(UriPartial.Path)); - -// await source.DownloadReleaseEntry(releases[0], "test", null); -// Assert.Equal(baseUrl + "/" + releases[0].Filename, new Uri(dl.LastUrl).GetLeftPart(UriPartial.Path)); -// } - -// [Theory] -// [InlineData("http://example.com", "MyPackage.nupkg", "http://example.com/MyPackage.nupkg")] -// [InlineData("http://example.com?auth=hello", "MyPackage.nupkg", "http://example.com/MyPackage.nupkg?auth=hello")] -// [InlineData("http://example.com?auth=hello", "https://my.packages.domain/MyPackage-1.0.0.nupkg", "https://my.packages.domain/MyPackage-1.0.0.nupkg")] -// public async Task SimpleWebSourcePreservesQueryParametersAndAbsoluteReleaseUri(string baseUri, string releaseUri, string expectedPackageUrl) -// { -// var dl = new FakeDownloader(); -// var source = new Sources.SimpleWebSource(baseUri, dl); -// var baseKvp = HttpUtility.ParseQueryString(new Uri(baseUri).Query); -// var baseDict = baseKvp.AllKeys.Where(k => k != null).ToDictionary(k => k, k => baseKvp[k]); - -// var releaseEntry = $"94689fede03fed7ab59c24337673a27837f0c3ec {releaseUri} 1004502"; -// dl.MockedResponseBytes = Encoding.UTF8.GetBytes(releaseEntry); - -// var releases = await source.GetReleaseFeed(); -// var expected = new Uri(baseUri).GetLeftPart(UriPartial.Path).TrimEnd('/') + "/RELEASES"; -// Assert.StartsWith(expected, dl.LastUrl); - -// // check that each query parameter in base url is in the releases string -// var releasesUri = new Uri(dl.LastUrl); -// var releasesKvp = HttpUtility.ParseQueryString(releasesUri.Query); -// var releasesDict = releasesKvp.AllKeys.Where(k => k != null).ToDictionary(k => k, k => releasesKvp[k]); -// foreach (var kvp in baseDict) { -// Assert.Equal(releasesDict[kvp.Key], kvp.Value); -// } - -// await source.DownloadReleaseEntry(releases[0], "test", null); -// Assert.Equal(expectedPackageUrl, dl.LastUrl); -// } -// } -//} diff --git a/test/Velopack.Tests/UpdateManager/DownloadReleasesTests.cs b/test/Velopack.Tests/UpdateManager/DownloadReleasesTests.cs deleted file mode 100644 index d4642fbc..00000000 --- a/test/Velopack.Tests/UpdateManager/DownloadReleasesTests.cs +++ /dev/null @@ -1,194 +0,0 @@ -//using System; -//using System.Collections.Generic; -//using System.IO; -//using System.Linq; -//using System.Net; -//using System.Text; -//using System.Threading.Tasks; -//using Squirrel.SimpleSplat; -//using Squirrel.Tests.TestHelpers; -//using Xunit; - -//namespace Squirrel.Tests -//{ -// public class DownloadReleasesTests -// { -// [Fact(Skip = "Rewrite this to be an integration test")] -// public void ChecksumShouldFailIfFilesAreMissing() -// { -// Assert.Fail("Rewrite this to be an integration test"); - -// /* -// var filename = "Squirrel.Core.1.0.0.0.nupkg"; -// var nuGetPkg = IntegrationTestHelper.GetPath("fixtures", filename); -// var fs = new Mock(); -// var urlDownloader = new Mock(); - -// ReleaseEntry entry; -// using (var f = File.OpenRead(nuGetPkg)) { -// entry = ReleaseEntry.GenerateFromFile(f, filename); -// } - -// var fileInfo = new Mock(); -// fileInfo.Setup(x => x.OpenRead()).Returns(File.OpenRead(nuGetPkg)); -// fileInfo.Setup(x => x.Exists).Returns(false); - -// fs.Setup(x => x.GetFileInfo(Path.Combine(".", "theApp", "packages", filename))).Returns(fileInfo.Object); - -// var fixture = ExposedObject.From( -// new UpdateManager("http://lol", "theApp", ".", fs.Object, urlDownloader.Object)); - -// bool shouldDie = true; -// try { -// // NB: We can't use Assert.Throws here because the binder -// // will try to pick the wrong method -// fixture.checksumPackage(entry); -// } catch (Exception) { -// shouldDie = false; -// } - -// shouldDie.ShouldBeFalse(); -// */ -// } - -// [Fact(Skip = "Rewrite this to be an integration test")] -// public void ChecksumShouldFailIfFilesAreBogus() -// { -// Assert.Fail("Rewrite this to be an integration test"); - -// /* -// var filename = "Squirrel.Core.1.0.0.0.nupkg"; -// var nuGetPkg = IntegrationTestHelper.GetPath("fixtures", filename); -// var fs = new Mock(); -// var urlDownloader = new Mock(); - -// ReleaseEntry entry; -// using (var f = File.OpenRead(nuGetPkg)) { -// entry = ReleaseEntry.GenerateFromFile(f, filename); -// } - -// var fileInfo = new Mock(); -// fileInfo.Setup(x => x.OpenRead()).Returns(new MemoryStream(Encoding.UTF8.GetBytes("Lol broken"))); -// fileInfo.Setup(x => x.Exists).Returns(true); -// fileInfo.Setup(x => x.Length).Returns(new FileInfo(nuGetPkg).Length); -// fileInfo.Setup(x => x.Delete()).Verifiable(); - -// fs.Setup(x => x.GetFileInfo(Path.Combine(".", "theApp", "packages", filename))).Returns(fileInfo.Object); - -// var fixture = ExposedObject.From( -// new UpdateManager("http://lol", "theApp", ".", fs.Object, urlDownloader.Object)); - -// bool shouldDie = true; -// try { -// fixture.checksumPackage(entry); -// } catch (Exception ex) { -// this.Log().InfoException("Checksum failure", ex); -// shouldDie = false; -// } - -// shouldDie.ShouldBeFalse(); -// fileInfo.Verify(x => x.Delete(), Times.Once()); -// */ -// } - -// [Fact(Skip = "Rewrite this to be an integration test")] -// public async Task DownloadReleasesFromHttpServerIntegrationTest() -// { -// Assert.Fail("Rewrite this to not use the SampleUpdatingApp"); - -// /* -// string tempDir = null; - -// var updateDir = new DirectoryInfo(IntegrationTestHelper.GetPath("..", "SampleUpdatingApp", "SampleReleasesFolder")); - -// IDisposable disp; -// try { -// var httpServer = new StaticHttpServer(30405, updateDir.FullName); -// disp = httpServer.Start(); -// } catch (HttpListenerException) { -// Assert.False(true, @"Windows sucks, go run 'netsh http add urlacl url=http://+:30405/ user=MYMACHINE\MyUser"); -// return; -// } - -// var entriesToDownload = updateDir.GetFiles("*.nupkg") -// .Select(x => ReleaseEntry.GenerateFromFile(x.FullName)) -// .ToArray(); - -// entriesToDownload.Count().ShouldBeGreaterThan(0); - -// using (disp) -// using (Utility.WithTempDirectory(out tempDir)) { -// // NB: This is normally done by CheckForUpdates, but since -// // we're skipping that in the test we have to do it ourselves -// Directory.CreateDirectory(Path.Combine(tempDir, "SampleUpdatingApp", "packages")); - -// var fixture = new UpdateManager("http://localhost:30405", "SampleUpdatingApp", tempDir); -// using (fixture) { -// var progress = new List(); -// await fixture.DownloadReleases(entriesToDownload, progress.Add); - -// progress -// .Aggregate(0, (acc, x) => { x.ShouldBeGreaterThan(acc); return x; }) -// .ShouldEqual(100); -// } - -// entriesToDownload.ForEach(x => { -// this.Log().Info("Looking for {0}", x.Filename); -// var actualFile = Path.Combine(tempDir, "SampleUpdatingApp", "packages", x.Filename); -// File.Exists(actualFile).ShouldBeTrue(); - -// var actualEntry = ReleaseEntry.GenerateFromFile(actualFile); -// actualEntry.SHA1.ShouldEqual(x.SHA1); -// actualEntry.Version.ShouldEqual(x.Version); -// }); -// } -// */ -// } - -// [Fact(Skip = "Rewrite this to be an integration test")] -// public async Task DownloadReleasesFromFileDirectoryIntegrationTest() -// { -// Assert.Fail("Rewrite this to not use the SampleUpdatingApp"); - -// /* -// string tempDir = null; - -// var updateDir = new DirectoryInfo(IntegrationTestHelper.GetPath("..", "SampleUpdatingApp", "SampleReleasesFolder")); - -// var entriesToDownload = updateDir.GetFiles("*.nupkg") -// .Select(x => ReleaseEntry.GenerateFromFile(x.FullName)) -// .ToArray(); - -// entriesToDownload.Count().ShouldBeGreaterThan(0); - -// using (Utility.WithTempDirectory(out tempDir)) { -// // NB: This is normally done by CheckForUpdates, but since -// // we're skipping that in the test we have to do it ourselves -// Directory.CreateDirectory(Path.Combine(tempDir, "SampleUpdatingApp", "packages")); - -// var fixture = new UpdateManager(updateDir.FullName, "SampleUpdatingApp", tempDir); -// using (fixture) { -// var progress = new List(); - -// await fixture.DownloadReleases(entriesToDownload, progress.Add); -// this.Log().Info("Progress: [{0}]", String.Join(",", progress)); - -// progress -// .Aggregate(0, (acc, x) => { x.ShouldBeGreaterThan(acc); return x; }) -// .ShouldEqual(100); -// } - -// entriesToDownload.ForEach(x => { -// this.Log().Info("Looking for {0}", x.Filename); -// var actualFile = Path.Combine(tempDir, "SampleUpdatingApp", "packages", x.Filename); -// File.Exists(actualFile).ShouldBeTrue(); - -// var actualEntry = ReleaseEntry.GenerateFromFile(actualFile); -// actualEntry.SHA1.ShouldEqual(x.SHA1); -// actualEntry.Version.ShouldEqual(x.Version); -// }); -// } -// */ -// } -// } -//} diff --git a/test/Velopack.Tests/UpdateManager/UpdateManagerTests.cs b/test/Velopack.Tests/UpdateManager/UpdateManagerTests.cs deleted file mode 100644 index 6ed26f7e..00000000 --- a/test/Velopack.Tests/UpdateManager/UpdateManagerTests.cs +++ /dev/null @@ -1,367 +0,0 @@ -//using System; -//using System.Collections.Generic; -//using System.IO; -//using System.Linq; -//using System.Text; -//using System.Threading; -//using System.Threading.Tasks; -//using Microsoft.Win32; -//using Squirrel; -//using Squirrel.Tests.TestHelpers; -//using Xunit; -//using System.Net; -//using Squirrel.NuGet; -//using System.Net.Http; -//using NuGet.Versioning; -//using Squirrel.Sources; - -//namespace Squirrel.Tests -//{ -// public class UpdateManagerTests -// { -// public const string APP_ID = "theFakeApp"; - -// public class CreateUninstallerRegKeyTests -// { -// [Fact] -// public async Task CallingMethodTwiceShouldUpdateInstaller() -// { -// using var _1 = Utility.GetTempDirectory(out var path); -// using var _2 = Utility.GetTempDirectory(out var remotePkgDir); - -// IntegrationTestHelper.CreateNewVersionInPackageDir("0.1.0", remotePkgDir); -// using (var fixture = UpdateManagerTestImpl.FromLocalPackageTempDir(remotePkgDir, APP_ID, path)) -// await fixture.FullInstall(); - -// using (var mgr = UpdateManagerTestImpl.FromLocalPackageTempDir(remotePkgDir, APP_ID, path)) { -// await mgr.CreateUninstallerRegistryEntry(); -// var regKey = await mgr.CreateUninstallerRegistryEntry(); - -// Assert.False(String.IsNullOrWhiteSpace((string) regKey.GetValue("DisplayName"))); - -// mgr.RemoveUninstallerRegistryEntry(); -// } - -// // NB: Squirrel-Aware first-run might still be running, slow -// // our roll before blowing away the temp path -// Thread.Sleep(1000); - -// var key = RegistryKey.OpenBaseKey(RegistryHive.CurrentUser, RegistryView.Default) -// .OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Uninstall"); -// using (key) { -// Assert.False(key.GetSubKeyNames().Contains(APP_ID)); -// } -// } - -// public class UpdateLocalReleasesTests -// { -// [Fact] -// public async Task UpdateLocalReleasesSmokeTest() -// { -// using var _1 = Utility.GetTempDirectory(out var tempDir); - -// var appDir = Path.Combine(tempDir, APP_ID); -// var packageDir = Directory.CreateDirectory(Path.Combine(appDir, "packages")); - -// 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 => File.Copy(IntegrationTestHelper.GetPath("fixtures", x), Path.Combine(tempDir, APP_ID, "packages", x))); - -// var info = new AppDescWindows(appDir, APP_ID); -// ReleaseEntry.BuildReleasesFile(info.PackagesDir); - -// var releasePath = Path.Combine(packageDir.FullName, "RELEASES"); -// File.Exists(releasePath).ShouldBeTrue(); - -// var entries = ReleaseEntry.ParseReleaseFile(File.ReadAllText(releasePath, Encoding.UTF8)); -// entries.Count().ShouldEqual(3); -// } - -// [Fact] -// public async Task InitialInstallSmokeTest() -// { -// using var _1 = Utility.GetTempDirectory(out var tempDir); - -// var remotePackageDir = Directory.CreateDirectory(Path.Combine(tempDir, "remotePackages")); -// var localAppDir = Path.Combine(tempDir, APP_ID); - -// new[] { -// "Squirrel.Core.1.0.0.0-full.nupkg", -// }.ForEach(x => File.Copy(IntegrationTestHelper.GetPath("fixtures", x), Path.Combine(remotePackageDir.FullName, x))); - -// using var fixture = UpdateManagerTestImpl.FromLocalPackageTempDir(remotePackageDir.FullName, APP_ID, tempDir); -// await fixture.FullInstall(); - -// var releasePath = Path.Combine(localAppDir, "packages", "RELEASES"); -// File.Exists(releasePath).ShouldBeTrue(); - -// var entries = ReleaseEntry.ParseReleaseFile(File.ReadAllText(releasePath, Encoding.UTF8)); -// entries.Count().ShouldEqual(1); - -// Assert.True(File.Exists(Path.Combine(localAppDir, "current", "ReactiveUI.dll"))); -// Assert.True(File.Exists(Path.Combine(localAppDir, "current", "NSync.Core.dll"))); - -// var manifest = NuspecManifest.ParseFromFile(Path.Combine(localAppDir, "current", Utility.SpecVersionFileName)); -// Assert.Equal(new NuGetVersion(1, 0, 0, 0), manifest.Version); -// } - -// [Fact] -// public async Task SpecialCharactersInitialInstallTest() -// { -// using var _1 = Utility.GetTempDirectory(out var tempDir); - -// var remotePackageDir = Directory.CreateDirectory(Path.Combine(tempDir, "remotePackages")); -// var localAppDir = Path.Combine(tempDir, APP_ID); - -// new[] { -// "SpecialCharacters-0.1.0-full.nupkg", -// }.ForEach(x => File.Copy(IntegrationTestHelper.GetPath("fixtures", x), Path.Combine(remotePackageDir.FullName, x))); - -// using var fixture = UpdateManagerTestImpl.FromLocalPackageTempDir(remotePackageDir.FullName, APP_ID, tempDir); -// await fixture.FullInstall(); - -// var releasePath = Path.Combine(localAppDir, "packages", "RELEASES"); -// File.Exists(releasePath).ShouldBeTrue(); - -// var entries = ReleaseEntry.ParseReleaseFile(File.ReadAllText(releasePath, Encoding.UTF8)); -// entries.Count().ShouldEqual(1); - -// new[] { -// "file space name.txt" -// }.ForEach(x => File.Exists(Path.Combine(localAppDir, "current", x)).ShouldBeTrue()); -// } - -// [Fact] -// public async Task WhenBothFilesAreInSyncNoUpdatesAreApplied() -// { -// using var _1 = Utility.GetTempDirectory(out var tempDir); - -// var appDir = Path.Combine(tempDir, APP_ID); -// 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)); -// File.Copy(path, Path.Combine(remotePackages, x)); -// }); - -// // sync both release files -// var info = new AppDescWindows(appDir, APP_ID); -// ReleaseEntry.BuildReleasesFile(info.PackagesDir); -// ReleaseEntry.BuildReleasesFile(remotePackages); - -// // check for an update -// using var mgr = UpdateManagerTestImpl.FromLocalPackageTempDir(remotePackages, APP_ID, tempDir); -// UpdateInfo updateInfo = await mgr.CheckForUpdate(); - -// Assert.NotNull(updateInfo); -// Assert.Empty(updateInfo.ReleasesToApply); -// } - -// [Fact] -// public async Task WhenRemoteReleasesDoNotHaveDeltasNoUpdatesAreApplied() -// { -// using var _1 = Utility.GetTempDirectory(out var tempDir); - -// var appDir = Path.Combine(tempDir, APP_ID); -// 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)); -// }); - -// // sync both release files -// var info = new AppDescWindows(appDir, APP_ID); -// ReleaseEntry.BuildReleasesFile(info.PackagesDir); -// ReleaseEntry.BuildReleasesFile(remotePackages); - -// using var mgr = UpdateManagerTestImpl.FromLocalPackageTempDir(remotePackages, APP_ID, tempDir); -// UpdateInfo updateInfo = await mgr.CheckForUpdate(); - -// Assert.NotNull(updateInfo); -// Assert.Empty(updateInfo.ReleasesToApply); -// } - -// [Fact] -// public async Task WhenTwoRemoteUpdatesAreAvailableChoosesDeltaVersion() -// { -// using var _1 = Utility.GetTempDirectory(out var tempDir); - -// var appDir = Path.Combine(tempDir, APP_ID); -// 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)); -// }); - -// // sync both release files -// var info = new AppDescWindows(appDir, APP_ID); -// ReleaseEntry.BuildReleasesFile(info.PackagesDir); -// ReleaseEntry.BuildReleasesFile(remotePackages); - -// using var mgr = UpdateManagerTestImpl.FromLocalPackageTempDir(remotePackages, APP_ID, tempDir); -// UpdateInfo updateInfo = await mgr.CheckForUpdate(); - -// Assert.True(updateInfo.ReleasesToApply.First().IsDelta); - -// updateInfo = await mgr.CheckForUpdate(ignoreDeltaUpdates: true); -// Assert.False(updateInfo.ReleasesToApply.First().IsDelta); -// } - -// [Fact] -// public async Task WhenFolderDoesNotExistThrowHelpfulError() -// { -// using var _1 = Utility.GetTempDirectory(out var tempDir); -// var directory = Path.Combine(tempDir, "missing-folder"); -// using var fixture = UpdateManagerTestImpl.FromLocalPackageTempDir(directory, APP_ID, tempDir); -// await Assert.ThrowsAsync(() => fixture.CheckForUpdate()); -// } - -// [Fact] -// public async Task WhenReleasesFileDoesntExistThrowACustomError() -// { -// using var _1 = Utility.GetTempDirectory(out var tempDir); -// var directory = Path.Combine(tempDir, "folder"); -// Directory.CreateDirectory(directory); -// using var fixture = UpdateManagerTestImpl.FromLocalPackageTempDir(directory, APP_ID, tempDir); -// await Assert.ThrowsAsync(() => fixture.CheckForUpdate()); -// } - -// [Fact] -// public async Task WhenReleasesFileIsBlankThrowAnException() -// { -// using var _1 = Utility.GetTempDirectory(out var tempDir); -// 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()); -// } - -// [Fact] -// public async Task WhenUrlResultsInWebExceptionWeShouldThrow() -// { -// // This should result in a WebException (which gets caught) unless you can actually access 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()); -// } - -// [Fact] -// public void IsInstalledHandlesInvalidDirectoryStructure() -// { -// using (Utility.GetTempDirectory(out var tempDir)) { -// Directory.CreateDirectory(Path.Combine(tempDir, APP_ID)); -// Directory.CreateDirectory(Path.Combine(tempDir, APP_ID, "app-1.0.1")); -// Directory.CreateDirectory(Path.Combine(tempDir, APP_ID, "wrongDir")); -// File.WriteAllText(Path.Combine(tempDir, APP_ID, "Update.exe"), "1"); -// using (var fixture = UpdateManagerTestImpl.FromFakeWebSource("http://lol", APP_ID, tempDir)) { -// Assert.Null(new AppDescWindows(Path.Combine(tempDir, "app.exe")).CurrentlyInstalledVersion); -// Assert.Null(new AppDescWindows(Path.Combine(tempDir, APP_ID, "app.exe")).CurrentlyInstalledVersion); -// Assert.Null(new AppDescWindows(Path.Combine(tempDir, APP_ID, "wrongDir", "app.exe")).CurrentlyInstalledVersion); -// Assert.Equal(new SemanticVersion(1, 0, 9), -// new AppDescWindows(Path.Combine(tempDir, APP_ID, "app-1.0.9", "app.exe")).CurrentlyInstalledVersion); -// } -// } -// } - -// [Fact] -// public void CurrentlyInstalledVersionDoesNotThrow() -// { -// using var fixture = new UpdateManager(); -// Assert.Null(fixture.CurrentlyInstalledVersion()); -// Assert.False(fixture.IsInstalledApp); -// } - -// [Theory] -// [InlineData(0, 0, 25, 0)] -// [InlineData(12, 0, 25, 3)] -// [InlineData(55, 0, 25, 13)] -// [InlineData(100, 0, 25, 25)] -// [InlineData(0, 25, 50, 25)] -// [InlineData(12, 25, 50, 28)] -// [InlineData(55, 25, 50, 38)] -// [InlineData(100, 25, 50, 50)] -// public void CalculatesPercentageCorrectly(int percentageOfCurrentStep, int stepStartPercentage, int stepEndPercentage, int expectedPercentage) -// { -// var percentage = Utility.CalculateProgress(percentageOfCurrentStep, stepStartPercentage, stepEndPercentage); - -// Assert.Equal(expectedPercentage, percentage); -// } - -// [Fact] -// public void CalculatesPercentageCorrectlyForUpdateExe() -// { -// // Note: this mimicks the update.exe progress reporting of multiple steps - -// var progress = new List(); - -// // 3 % (3 stages), check for updates -// foreach (var step in new[] { 0, 33, 66, 100 }) { -// progress.Add(Utility.CalculateProgress(step, 0, 3)); - -// Assert.InRange(progress.Last(), 0, 3); -// } - -// Assert.Equal(3, progress.Last()); - -// // 3 - 30 %, download releases -// for (var step = 0; step <= 100; step++) { -// progress.Add(Utility.CalculateProgress(step, 3, 30)); - -// Assert.InRange(progress.Last(), 3, 30); -// } - -// Assert.Equal(30, progress.Last()); - -// // 30 - 100 %, apply releases -// for (var step = 0; step <= 100; step++) { -// progress.Add(Utility.CalculateProgress(step, 30, 100)); - -// Assert.InRange(progress.Last(), 30, 100); -// } - -// Assert.Equal(100, progress.Last()); -// } -// } -// } -// } -//} \ No newline at end of file