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:
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;
|
||||
Reference in New Issue
Block a user