mirror of
https://github.com/velopack/velopack.git
synced 2025-10-25 15:19:22 +00:00
Add full update integration test
This commit is contained in:
19
test/TestApp/ConsoleLogger.cs
Normal file
19
test/TestApp/ConsoleLogger.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
class ConsoleLogger : ILogger
|
||||
{
|
||||
public IDisposable BeginScope<TState>(TState state) where TState : notnull
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public bool IsEnabled(LogLevel logLevel)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func<TState, Exception, string> formatter)
|
||||
{
|
||||
Console.WriteLine(formatter(state, exception));
|
||||
}
|
||||
}
|
||||
1
test/TestApp/Const.cs
Normal file
1
test/TestApp/Const.cs
Normal file
@@ -0,0 +1 @@
|
||||
class Const { public const string TEST_STRING = "Hello, World!"; }
|
||||
64
test/TestApp/Program.cs
Normal file
64
test/TestApp/Program.cs
Normal file
@@ -0,0 +1,64 @@
|
||||
using Squirrel;
|
||||
using Squirrel.Locators;
|
||||
|
||||
try {
|
||||
if (args.Length >= 1 && args[0].StartsWith("--squirrel")) {
|
||||
// squirrel hooks
|
||||
File.AppendAllText(Path.Combine(AppContext.BaseDirectory, "args.txt"), String.Join(" ", args) + Environment.NewLine);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (args.Length == 1 && args[0] == "version") {
|
||||
var locator = SquirrelLocator.GetDefault(new ConsoleLogger());
|
||||
Console.WriteLine(locator.CurrentlyInstalledVersion);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (args.Length == 1 && args[0] == "test") {
|
||||
Console.WriteLine(Const.TEST_STRING);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (args.Length == 2) {
|
||||
if (args[0] == "check") {
|
||||
var um = new UpdateManager(args[1], null, new ConsoleLogger());
|
||||
var info = um.CheckForUpdates();
|
||||
if (info == null) {
|
||||
Console.WriteLine("no updates");
|
||||
return 0;
|
||||
} else {
|
||||
Console.WriteLine("update: " + info.TargetFullRelease.Version);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (args[0] == "download") {
|
||||
var um = new UpdateManager(args[1], null, new ConsoleLogger());
|
||||
var info = um.CheckForUpdates();
|
||||
if (info == null) {
|
||||
Console.WriteLine("no updates");
|
||||
return -1;
|
||||
}
|
||||
um.DownloadUpdates(info, (x) => Console.WriteLine(x));
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (args[0] == "apply") {
|
||||
var um = new UpdateManager(args[1], null, new ConsoleLogger());
|
||||
if (!um.IsUpdatePendingRestart) {
|
||||
Console.WriteLine("not pending restart");
|
||||
return -1;
|
||||
}
|
||||
Console.WriteLine("applying...");
|
||||
um.ApplyUpdatesAndExit();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Exception ex) {
|
||||
Console.WriteLine("exception: " + ex.ToString());
|
||||
return -1;
|
||||
}
|
||||
|
||||
Console.WriteLine("Invalid args: " + String.Join(", ", args));
|
||||
return -1;
|
||||
13
test/TestApp/TestApp.csproj
Normal file
13
test/TestApp/TestApp.csproj
Normal file
@@ -0,0 +1,13 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\Squirrel\Squirrel.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
Reference in New Issue
Block a user