Remove more usages of "Squirrel"

This commit is contained in:
Caelan Sayler
2023-12-31 11:23:38 +00:00
parent 1d20f014d6
commit 374996f481
30 changed files with 73 additions and 1338 deletions

View File

@@ -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)
};

View File

@@ -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);

View File

@@ -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);

View File

@@ -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)) {

View File

@@ -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

View File

@@ -44,7 +44,7 @@ public class NugetConsole
{releaseNotesText}
</metadata>
<files>
<file src=""**"" target=""lib\squirrel\"" exclude=""{(includePdb ? "" : "*.pdb;")}*.nupkg;*.vshost.*;**\createdump.exe""/>
<file src=""**"" target=""lib\app\"" exclude=""{(includePdb ? "" : "*.pdb;")}*.nupkg;*.vshost.*;**\createdump.exe""/>
</files>
</package>
".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);

View File

@@ -22,7 +22,7 @@ public class OsxBundleCommand : OutputCommand
: base("bundle", "Create's an OSX .app bundle from a folder containing application files.")
{
AddOption<string>((v) => PackId = v, "--packId", "-u")
.SetDescription("Unique Squirrel Id for application bundle.")
.SetDescription("Unique Id for application bundle.")
.SetArgumentHelpName("ID")
.SetRequired()
.RequiresValidNuGetId();

View File

@@ -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<DirectoryInfo>((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")

View File

@@ -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<string>((v) => PackId = v, "--packId", "-u")
.SetDescription("Unique Id for application bundle.")

View File

@@ -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<FileInfo>((v) => Package = v.ToFullNameOrNull(), "-p", "--package")
.SetDescription("Path to a '.nupkg' package to releasify.")
@@ -31,7 +31,7 @@ public class WindowsReleasifyCommand : WindowsSigningCommand
/// <summary>
/// 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).
/// </summary>
protected WindowsReleasifyCommand(string name, string description)
: base(name, description)

View File

@@ -16,7 +16,7 @@ namespace Velopack.Vpk.Commands
: base(name, description)
{
ReleaseDirectoryOption = AddOption<DirectoryInfo>((v) => ReleaseDirectory = v.ToFullNameOrNull(), "-o", "--outputDir")
.SetDescription("Output directory for Squirrel packages.")
.SetDescription("Output directory for created packages.")
.SetArgumentHelpName("DIR")
.SetDefault(new DirectoryInfo(".\\Releases"));
}

View File

@@ -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<string, string> 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);

View File

@@ -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;
}

View File

@@ -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<IConfiguration>());
CliRootCommand rootCommand = new CliRootCommand(
$"Squirrel {VelopackRuntimeInfo.SquirrelDisplayVersion} for creating and distributing Squirrel releases.") {
$"Velopack CLI {VelopackRuntimeInfo.VelopackDisplayVersion} for creating and distributing releases.") {
VerboseOption,
};

View File

@@ -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)

View File

@@ -9,7 +9,7 @@ using Velopack.NuGet;
namespace Velopack.Locators
{
/// <summary>
/// An implementation for Windows which uses the Squirrel default paths.
/// An implementation for Windows which uses the default paths.
/// </summary>
[SupportedOSPlatform("windows")]
public class WindowsVelopackLocator : VelopackLocator

View File

@@ -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);

View File

@@ -25,7 +25,7 @@ namespace Velopack
}
/// <summary>
/// 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.
/// </summary>
[DataContract]

View File

@@ -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();

View File

@@ -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();

View File

@@ -13,9 +13,9 @@ namespace Velopack.Sources
public class HttpClientFileDownloader : IFileDownloader
{
/// <summary>
/// The User-Agent sent with Squirrel requests
/// The User-Agent sent with requests
/// </summary>
public static ProductInfoHeaderValue UserAgent => new("Squirrel", VelopackRuntimeInfo.SquirrelNugetVersion.ToFullString());
public static ProductInfoHeaderValue UserAgent => new("Velopack", VelopackRuntimeInfo.VelopackNugetVersion.ToFullString());
/// <inheritdoc />
public virtual async Task DownloadFile(string url, string targetFile, Action<int> progress, string authorization, string accept)

View File

@@ -19,7 +19,7 @@ namespace Velopack
/// </summary>
public class UpdateManager
{
/// <summary> The currently installed Squirrel application Id. This would be what you set when you create your Squirrel release.</summary>
/// <summary> The currently installed application Id. This would be what you set when you create your release.</summary>
public virtual string AppId => Locator.AppId;
/// <summary> True if this application is currently installed, and is able to download/check for updates. </summary>
@@ -36,7 +36,7 @@ namespace Velopack
}
}
/// <summary> The currently installed Squirrel app version when you created your release. Null if this is not a currently installed app. </summary>
/// <summary> The currently installed app version when you created your release. Null if this is not a currently installed app. </summary>
public virtual SemanticVersion CurrentVersion => Locator.CurrentlyInstalledVersion;
/// <summary> The update source to use when checking for/downloading updates. </summary>

View File

@@ -40,12 +40,12 @@ namespace Velopack
}
/// <summary>
/// Creates and returns a new Squirrel application builder.
/// Creates and returns a new Velopack application builder.
/// </summary>
public static VelopackApp Build() => new VelopackApp();
/// <summary>
/// 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.
/// </summary>
public VelopackApp SetArgs(string[] args)
@@ -82,7 +82,7 @@ namespace Velopack
}
/// <summary>
/// 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.
/// </summary>
public VelopackApp WithRestarted(VelopackHook hook)
{
@@ -91,7 +91,7 @@ namespace Velopack
}
/// <summary>
/// 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 <see cref="Environment.Exit(int)"/> 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
}
/// <summary>
/// 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 <see cref="Environment.Exit(int)"/> 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
}
/// <summary>
/// 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 <see cref="Environment.Exit(int)"/> 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
}
/// <summary>
/// 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 <see cref="Environment.Exit(int)"/> 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
}
/// <summary>
/// Runs the Squirrel application startup code and triggers any configured hooks.
/// Runs the Velopack application startup code and triggers any configured hooks.
/// </summary>
/// <param name="logger">A logging interface for diagnostic messages.</param>
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)");
}
}
}

View File

@@ -79,14 +79,14 @@ namespace Velopack
/// </summary>
public static class VelopackRuntimeInfo
{
/// <summary> The current compiled Squirrel display version. </summary>
public static string SquirrelDisplayVersion { get; }
/// <summary> The current compiled Velopack display version. </summary>
public static string VelopackDisplayVersion { get; }
/// <summary> The current compiled Squirrel NuGetVersion. </summary>
public static NuGetVersion SquirrelNugetVersion { get; }
/// <summary> The current compiled Velopack NuGetVersion. </summary>
public static NuGetVersion VelopackNugetVersion { get; }
/// <summary> The current compiled Squirrel assembly file version. </summary>
public static string SquirrelFileVersion => ThisAssembly.AssemblyFileVersion;
/// <summary> The current compiled Velopack assembly file version. </summary>
public static string VelopackFileVersion => ThisAssembly.AssemblyFileVersion;
/// <summary> The path on disk of the entry assembly. </summary>
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

View File

@@ -174,7 +174,7 @@ namespace Velopack.Windows
public NuGetVersion MinVersion { get; }
/// <summary> 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. </summary>
/// For example, if the app was deployed with 'win-x64', this must be X64 also. </summary>
public RuntimeCpu CpuArchitecture { get; }
/// <summary> The type of runtime required, eg. Windows Desktop, AspNetCore, Sdk.</summary>

View File

@@ -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
{

View File

@@ -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<Exception>(
// () => 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<int>();
// 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<int>();
// 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<int>();
// 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<int>();
// 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);
// // }
// //}
// }
//}

View File

@@ -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<FileInfoBase>();
// fileInfo.Setup(x => x.OpenRead())
// .Returns(File.OpenRead(IntegrationTestHelper.GetPath("fixtures", "RELEASES-OnePointOh")));
// var fs = new Mock<IFileSystemFactory>();
// fs.Setup(x => x.GetFileInfo(localReleasesFile)).Returns(fileInfo.Object);
// var urlDownloader = new Mock<IUrlDownloader>();
// var dlPath = IntegrationTestHelper.GetPath("fixtures", "RELEASES-OnePointOne");
// urlDownloader.Setup(x => x.DownloadUrl(It.IsAny<string>(), It.IsAny<IObserver<int>>()))
// .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<FileInfoBase>();
// 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<DirectoryInfoBase>();
// dirInfo.Setup(x => x.Exists).Returns(true);
// var fs = new Mock<IFileSystemFactory>();
// 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<IUrlDownloader>();
// var dlPath = IntegrationTestHelper.GetPath("fixtures", "RELEASES-OnePointOne");
// urlDownloader.Setup(x => x.DownloadUrl(It.IsAny<string>(), It.IsAny<IObserver<int>>()))
// .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<FileInfoBase>();
// fileInfo.Setup(x => x.Exists).Returns(false);
// var dirInfo = new Mock<DirectoryInfoBase>();
// dirInfo.Setup(x => x.Exists).Returns(true);
// var fs = new Mock<IFileSystemFactory>();
// 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<IUrlDownloader>();
// urlDownloader.Setup(x => x.DownloadUrl(It.IsAny<string>(), It.IsAny<IObserver<int>>()))
// .Returns(Observable.Return("lol this isn't right"));
// var fixture = new UpdateManager("http://lol", "theApp", ".", fs.Object, urlDownloader.Object);
// using (fixture) {
// Assert.Throws<Exception>(() => 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);
// }
// }
//}

View File

@@ -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<IFileSystemFactory>();
// var urlDownloader = new Mock<IUrlDownloader>();
// ReleaseEntry entry;
// using (var f = File.OpenRead(nuGetPkg)) {
// entry = ReleaseEntry.GenerateFromFile(f, filename);
// }
// var fileInfo = new Mock<FileInfoBase>();
// 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<IFileSystemFactory>();
// var urlDownloader = new Mock<IUrlDownloader>();
// ReleaseEntry entry;
// using (var f = File.OpenRead(nuGetPkg)) {
// entry = ReleaseEntry.GenerateFromFile(f, filename);
// }
// var fileInfo = new Mock<FileInfoBase>();
// 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<int>();
// 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<int>();
// 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);
// });
// }
// */
// }
// }
//}

View File

@@ -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<Exception>(() => 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<Exception>(() => 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<int>();
// // 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());
// }
// }
// }
// }
//}