Merge remote-tracking branch 'origin/main' into claude/spelunk-api-key-tenant-6373cf

This commit is contained in:
laurens committed 2026-10-20 17:05:56 +02:00
commit 8543c69cca
8 files changed
+238 -29

No files matched your search

@@ -86,19 +86,86 @@ public sealed class LinuxUpdateChannelTests : IDisposable
}
/// <summary>
/// A machine that cannot say what it has treats everything as newer.
/// A machine that cannot say what it has is told so, and is offered nothing.
/// </summary>
/// <remarks>
/// The wrong way to fail, chosen deliberately and for the reason the android channel gives: the cost is
/// an install the package manager declines, and the cost of the other direction is a security fix that
/// never arrives.
/// This used to read the silence as <c>0</c> and offer everything, on the argument that the cost was
/// an install the package manager declined. On a machine with no rpm at all — a pacman package of the
/// same tree at the same path — that was every nightly, every six hours, as a 56 MB download nothing
/// could install. Unknown is not older.
/// </remarks>
[Fact]
public async Task AnUnknownInstalledVersionTreatsEverythingAsNewer()
public async Task AnUnknownInstalledVersionThrowsRatherThanOfferingAnything()
{
var channel = Channel(RandomNumberGenerator.GetBytes(16), published: "0.0.1~alpha.0.1-1", installed: null);
var handed = new List<string>();
var channel = Channel(
RandomNumberGenerator.GetBytes(16),
published: "0.0.1~alpha.0.200-1",
installed: null,
handToInstaller: handed.Add);
(await channel.CheckAsync(Token)).ShouldNotBeNull();
await Should.ThrowAsync<InvalidOperationException>(async () => await channel.CheckAsync(Token));
await Should.ThrowAsync<InvalidOperationException>(
async () => await channel.DownloadAsync(
new DodoSSH.Client.Session.AvailableUpdate("0.0.1-alpha.0.200"),
new Progress<int>(),
Token));
handed.ShouldBeEmpty();
Directory.Exists(Path.Combine(directory, "updates")).ShouldBeFalse();
}
/// <summary>
/// A copy rpm does not own gets no channel at all, and a sentence saying whose it is to update.
/// </summary>
/// <remarks>
/// The case that matters: the right path and no rpm — a locally built pacman package that mirrors the
/// spec. No binary and no such package both arrive here as null.
/// </remarks>
[Fact]
public void ACopyRpmDoesNotOwn_IsUnavailableAndSaysWhy()
{
var asked = new List<string>();
var updates = LinuxUpdateChannel.ForInstall(
"nightly",
package =>
{
asked.Add(package);
return null;
},
() => throw new InvalidOperationException("Built a channel for a copy rpm does not own."));
asked.ShouldBe(["dodossh-nightly"]);
updates.IsSupported.ShouldBeFalse();
var reason = updates.ShouldBeOfType<DodoSSH.Client.Session.UnavailableUpdateChannel>().Reason;
reason.ShouldNotBeNull();
reason.ShouldContain("outside the dodossh-nightly RPM");
reason.ShouldContain("package manager that installed it");
}
[Fact]
public void ACopyRpmOwns_GetsTheChannel()
{
var asked = new List<string>();
var owned = new FakeUpdateChannel();
var updates = LinuxUpdateChannel.ForInstall(
"release",
package =>
{
asked.Add(package);
return "0.0.1-1";
},
() => owned);
asked.ShouldBe(["dodossh"]);
updates.ShouldBeSameAs(owned);
}
[Fact]
@@ -80,6 +80,32 @@ public sealed class UpdateFlowTests : IDisposable
Build().CurrentVersion.ShouldBe("0.4.2");
}
[Fact]
public void ABuildThatCannotReplaceItself_ForAReasonOfItsOwn_SaysThatInstead()
{
var updates = new UpdateViewModel(
new UnavailableUpdateChannel("Update it with the package manager that installed it."),
new ClientSettingsStore(Paths),
TimeProvider.System,
() => 0,
restart: _ => Task.CompletedTask);
updates.IsUnsupported.ShouldBeTrue();
updates.UnsupportedReason.ShouldBe("Update it with the package manager that installed it.");
updates.IsUnsupportedForTheUsualReason.ShouldBeFalse();
}
[Fact]
public void ABuildThatCannotReplaceItself_ForTheUsualReasons_LeavesTheScreenItsOwnSentence()
{
channel.IsSupported = false;
var updates = Build();
updates.UnsupportedReason.ShouldBeNull();
updates.IsUnsupportedForTheUsualReason.ShouldBeTrue();
}
[Fact]
public async Task ABackgroundPassThatFindsNothing_SaysNothing()
{