Files
DodoSSH/tests/DodoSSH.Client.App.Tests/RootChipNameTests.cs
jaap-jan 242280ce6b
ci / build and test (push) Successful in 2m15s
ci / android head (push) Successful in 3m24s
ci / desktop nightly (push) Successful in 43s
ci / api image (push) Successful in 33s
Name a root chip after the root, not with its whole path
The chip derivation was TrimEnd(separator), which is a name only for the
Windows drives it was written against: on Unix it made the / chip an empty
pill and the home chip the entire home path, drawn at full width in a header
column nothing bounds. A home directory deep enough — CI's per-job HOME is
forty-six characters — had that one chip walk the header's own buttons out of
the window at the session shell's 472-pixel budget, which is the half of the
runner's red suite the star-column fix before this one did not reach.

A chip says C:, /, ~, or a mount's last segment now; the full path stays on
its command parameter, where length costs nothing. RootChipNameTests pins the
derivation with fixed strings, so it no longer takes a machine with a deep
profile path to ask the question.
2026-08-08 22:38:41 +02:00

48 lines
1.9 KiB
C#

using DodoSSH.Client.Shell.ViewModels;
using DodoSSH.Client.Transfer;
namespace DodoSSH.Client.App.Tests;
/// <summary>What the local pane's root chips are called.</summary>
/// <remarks>
/// A chip carries a name and never a path — the path is the chip's command parameter, where its length costs
/// nothing. The derivation used to be <c>TrimEnd(separator)</c>, which is a name only for a Windows drive:
/// on Unix it made the <c>/</c> chip an empty pill and the home chip the whole home path, and a home
/// directory deep enough pushed the pane header's own buttons out of the window — CI's per-job HOME is what
/// finally said so. These pin the derivation with fixed strings, so the question no longer depends on how
/// long a path any particular machine keeps its profile under.
/// </remarks>
public sealed class RootChipNameTests
{
[Fact]
public void TheUnixRootIsASlash_NotAnEmptyPill() =>
TransfersViewModel.RootChipName("/").ShouldBe("/");
/// <remarks>
/// The one substitution rather than a shortening: every shell already means "my home directory" by
/// <c>~</c>, and the machine's real home path — however deep — stays on the chip's command alone.
/// </remarks>
[Fact]
public void TheHomeChipIsATilde_HoweverDeepHomeSits() =>
TransfersViewModel.RootChipName(LocalDirectory.Home).ShouldBe("~");
[Fact]
public void AMountNamesItselfByItsLastSegment() =>
TransfersViewModel.RootChipName("/media/usb0").ShouldBe("usb0");
/// <remarks>
/// Windows only, because the input only exists there — <c>LocalDirectory.Roots()</c> produces drive
/// roots on no other platform, and <c>Path.GetFileName</c> reads <c>C:\</c> differently on Unix.
/// </remarks>
[Fact]
public void AWindowsDriveKeepsItsTwoCharacterName()
{
if (!OperatingSystem.IsWindows())
{
return;
}
TransfersViewModel.RootChipName(@"C:\").ShouldBe("C:");
}
}