mirror of
https://github.com/ajisaacs/OpenNest.git
synced 2026-12-05 00:19:26 -05:00
The updater stopped checking once a download finished, so a copy left open overnight restarted into the first build published that evening and then, a minute after starting, updated again to the newest. Checks now continue: a newer version replaces the pending download, and if the feed is unreachable or the newer download fails, the update already on disk stays ready (read back from Velopack, which may clear older packages on failure). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
48 lines
1.9 KiB
C#
48 lines
1.9 KiB
C#
namespace OpenNest.WinForms.Tests;
|
|
|
|
public class UpdaterServiceTests
|
|
{
|
|
[Fact]
|
|
public async Task ManualCheckOutsideAnInstallationReportsNotInstalled()
|
|
{
|
|
// Test hosts never start through VelopackApp, so there is no locator.
|
|
using var updater = new UpdaterService(feedUrl: null, includeDevBuilds: false);
|
|
|
|
Assert.False(updater.CanUpdate);
|
|
Assert.Equal(UpdaterService.CheckResult.NotInstalled, await updater.CheckNowAsync());
|
|
Assert.False(updater.HasPendingUpdate);
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData("1.3.0-dev.12", null, true)]
|
|
[InlineData("1.3.0-dev.12", "1.3.0-dev.9", true)]
|
|
[InlineData("1.3.0", "1.3.0-dev.40", true)]
|
|
[InlineData("1.3.0-dev.9", "1.3.0-dev.9", false)]
|
|
[InlineData("1.3.0-dev.9", "1.3.0-dev.12", false)]
|
|
public void ANewerFeedVersionReplacesThePendingDownload(string available, string pending, bool replaces)
|
|
{
|
|
// A copy left open overnight must restart into the newest build, not the evening's.
|
|
var pendingVersion = pending is null ? null : Velopack.SemanticVersion.Parse(pending);
|
|
|
|
Assert.Equal(replaces,
|
|
UpdaterService.IsNewerThanPending(Velopack.SemanticVersion.Parse(available), pendingVersion));
|
|
}
|
|
|
|
[Fact]
|
|
public void NoFeedVersionKeepsThePendingDownload()
|
|
{
|
|
Assert.False(UpdaterService.IsNewerThanPending(null, Velopack.SemanticVersion.Parse("1.3.0-dev.9")));
|
|
Assert.False(UpdaterService.IsNewerThanPending(null, null));
|
|
}
|
|
|
|
[Fact]
|
|
public void VersionOutsideAnInstallationIsTheAssemblyVersionWithoutBuildMetadata()
|
|
{
|
|
using var updater = new UpdaterService(feedUrl: null, includeDevBuilds: false);
|
|
|
|
Assert.Equal(UpdaterService.DisplayVersion(), updater.CurrentVersion);
|
|
Assert.DoesNotContain("+", updater.CurrentVersion);
|
|
Assert.StartsWith("0.", updater.CurrentVersion);
|
|
}
|
|
}
|