CI / Build and test (push) Successful in 8m14s
CI / Windows tests and installer (push) Skipped
CI / YAML check (push) Successful in 7s
Release / Build, test and publish (push) Successful in 13m19s
CI / PostgreSQL 16 integration (push) Successful in 4m49s
CI / PostgreSQL 17 integration (push) Successful in 5m28s
CI / Docker image (push) Successful in 53s
Release / Server image (push) Failing after 10s
The owner renamed the product and moved the repository to the self-hosted Gitea (https://gitea.encke-hake.ts.net/BalboSoft/Chronos) for more control, and asked for Actions and a first automatic release with the server package and the Windows exe (docs/requests/2026-10-23-chronos-gitea.md). - Chronos everywhere: a byte-exact rename of contents and paths, then a per-language review of the forms the old name's ending had dictated. - Gitea instead of GitHub: the update check, licence, issue and support links read ChronosReleasesUrl; the update check takes the highest stable version, offers a pre-release build its final release and reports a repository it cannot see as a failed check. EULA, security policy and Gitea issue forms live at the repository root. - Gitea Actions for the Linux act_runner (.gitea/workflows): CI, release, nightly image and performance gates in the .NET SDK container with git checkout and the system SQLite. The release cross-compiles the Windows programs, checks their icon, version and DPI manifest, packs installers and zips, publishes the Gitea release and pushes the server image (REGISTRY_TOKEN). Windows-only tests run in an opt-in job on a Windows runner (WINDOWS_RUNNER). - New Chronos.Tools commands: zip, gitea-release, postgres-ci (replaces the docker-exec script, which Gitea's service containers do not allow; the throw-away server runs without durability) and pe-check. - Timed tests take their budget from TestTiming (CHRONOS_TEST_TIME_FACTOR, 3 on the shared runner; the weekly performance gates keep theirs). BREAKING CHANGE: programs, settings, data folders, file types, environment variables and the Docker image use the new name; nothing is migrated from Titano, which never had a release. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Alberto Balbo <alberto.balbo.96@gmail.com>
150 lines
6.1 KiB
C#
150 lines
6.1 KiB
C#
using System.Globalization;
|
|
using Chronos.Testing;
|
|
using Chronos.Uploader.Text;
|
|
using Chronos.Uploader.Uploads;
|
|
|
|
namespace Chronos.App.Tests.Uploader;
|
|
|
|
public sealed class UploaderTextTests
|
|
{
|
|
private static readonly CultureInfo En = CultureInfo.GetCultureInfo("en");
|
|
private static readonly CultureInfo It = CultureInfo.GetCultureInfo("it");
|
|
|
|
private static readonly QueueSummary Mockup = new(4_812, 96_200_000_000, 2_214, 2_201, 0, 0, 44_000_000_000, "2026-09-28_18-02-11_0413.CR2")
|
|
{
|
|
RemainingBytes = 93_480_000_000,
|
|
};
|
|
|
|
[Test]
|
|
public void QueueLineMatchesTheMockup()
|
|
{
|
|
var left = RateMeter.TimeLeft(Mockup.RemainingBytes, 38_000_000);
|
|
Assert.Equal("4,812 files · 96.2 GB · 38 MB/s · 41 min left", UploaderText.QueueLine(Mockup, QueueActivity.Running, 38_000_000, left, En));
|
|
}
|
|
|
|
[Test]
|
|
public void QueueLineFollowsTheCulture()
|
|
{
|
|
Assert.Equal("4.812 file · 96,2 GB · 38 MB/s · mancano 41 min", UploaderText.QueueLine(Mockup, QueueActivity.Running, 38_000_000, TimeSpan.FromMinutes(41), It));
|
|
}
|
|
|
|
[Test]
|
|
public void QueueLineNamesTheActivityWhenNotRunning()
|
|
{
|
|
Assert.Equal("4,812 files · 96.2 GB · Paused", UploaderText.QueueLine(Mockup, QueueActivity.Paused, 0, null, En));
|
|
Assert.Equal("4,812 files · 96.2 GB · Waiting for server", UploaderText.QueueLine(Mockup, QueueActivity.WaitingForServer, 0, null, En));
|
|
Assert.Equal("1 file · 25 MB · Done", UploaderText.QueueLine(Mockup with { Files = 1, Bytes = 25_000_000 }, QueueActivity.Done, 0, null, En));
|
|
Assert.Equal("Nothing queued", UploaderText.QueueLine(default, QueueActivity.Idle, 0, null, En));
|
|
}
|
|
|
|
[Test]
|
|
public void RunningLineOmitsRateAndTimeUntilKnown()
|
|
{
|
|
Assert.Equal("4,812 files · 96.2 GB", UploaderText.QueueLine(Mockup, QueueActivity.Running, 0, null, En));
|
|
}
|
|
|
|
[Test]
|
|
public void ProgressLineMatchesTheMockup()
|
|
{
|
|
Assert.Equal("2,214 of 4,812 sent · 2,201 verified by the server · 0 retries", UploaderText.ProgressLine(Mockup, En));
|
|
Assert.Equal("2,214 of 4,812 sent · 2,201 verified by the server · 1 retry", UploaderText.ProgressLine(Mockup with { Retries = 1, Failed = 3 }, En));
|
|
}
|
|
|
|
[Test]
|
|
public void FailuresHaveTheirOwnTextOnlyWhenThereAreAny()
|
|
{
|
|
Assert.Null(UploaderText.Failed(Mockup, En));
|
|
Assert.Equal("1,203 failed", UploaderText.Failed(Mockup with { Failed = 1_203 }, En));
|
|
// Italian participles agree with the number ("1 non riuscito", "3 non riusciti"): the count follows a label instead.
|
|
Assert.Equal("Non riusciti: 3", UploaderText.Failed(Mockup with { Failed = 3 }, It));
|
|
Assert.Equal("Non riusciti: 1", UploaderText.Failed(Mockup with { Failed = 1 }, It));
|
|
}
|
|
|
|
[Test]
|
|
public void ItalianProgressReadsForASingleFileToo()
|
|
{
|
|
Assert.Equal("Inviati: 1 di 1 · Verificati dal server: 1 · 0 nuovi tentativi",
|
|
UploaderText.ProgressLine(Mockup with { Files = 1, Sent = 1, Verified = 1 }, It));
|
|
}
|
|
|
|
[Test]
|
|
public void SizeUnitsFollowTheLanguage()
|
|
{
|
|
Assert.Equal("999 byte", UploaderText.Bytes(999, It));
|
|
Assert.Equal("1,5 KB", UploaderText.Bytes(1_536, It));
|
|
Assert.Equal("4,2 MB/s", UploaderText.Rate(4_240_000, It));
|
|
}
|
|
|
|
[Theory]
|
|
[Case(0.0, "0 B/s")]
|
|
[Case(950_000.0, "950 KB/s")]
|
|
[Case(4_240_000.0, "4.2 MB/s")]
|
|
[Case(38_400_000.0, "38 MB/s")]
|
|
[Case(1_260_000_000.0, "1.3 GB/s")]
|
|
public void RatesUseDecimalUnits(double bytesPerSecond, string expected) =>
|
|
Assert.Equal(expected, UploaderText.Rate(bytesPerSecond, En));
|
|
|
|
[Theory]
|
|
[Case(40.0, "40 s")]
|
|
[Case(299.0, "5 min")]
|
|
[Case(3_590.0, "1 h 00 m")]
|
|
[Case(7_500.0, "2 h 05 m")]
|
|
[Case(93_600.0, "1 d 2 h")]
|
|
public void DurationsAreCompact(double seconds, string expected) =>
|
|
Assert.Equal(expected, UploaderText.Duration(TimeSpan.FromSeconds(seconds), En));
|
|
|
|
[Theory]
|
|
[Case(999L, "999 B")]
|
|
[Case(1_536L, "1.5 KB")]
|
|
[Case(96_200_000_000L, "96.2 GB")]
|
|
[Case(1_900_000_000_000L, "1.9 TB")]
|
|
public void SizesUseDecimalUnits(long bytes, string expected) => Assert.Equal(expected, UploaderText.Bytes(bytes, En));
|
|
|
|
[Test]
|
|
public void TimeLeftNeedsAUsableRate()
|
|
{
|
|
Assert.Equal(TimeSpan.FromMinutes(41), RateMeter.TimeLeft(93_480_000_000, 38_000_000));
|
|
Assert.Equal(TimeSpan.Zero, RateMeter.TimeLeft(0, 0));
|
|
Assert.Null(RateMeter.TimeLeft(1_000, 10));
|
|
}
|
|
|
|
[Test]
|
|
public void RateMeterAveragesTheWindowAndDecaysWhenStalled()
|
|
{
|
|
var meter = new RateMeter(TimeSpan.FromSeconds(10));
|
|
Assert.Equal(0.0, meter.BytesPerSecond(TimeSpan.Zero));
|
|
for (var s = 0; s <= 20; s++) meter.Add(4_000_000, TimeSpan.FromSeconds(s));
|
|
Assert.Approximately(4_000_000, meter.BytesPerSecond(TimeSpan.FromSeconds(20)), 1);
|
|
// Nothing sent for 20 s: the window holds no transfer any more.
|
|
Assert.Equal(0.0, meter.BytesPerSecond(TimeSpan.FromSeconds(40)));
|
|
meter.Reset();
|
|
Assert.Equal(0.0, meter.BytesPerSecond(TimeSpan.FromSeconds(40)));
|
|
}
|
|
|
|
[Test]
|
|
public void SummaryCountsStatesAndBytes()
|
|
{
|
|
var queue = new UploadQueue();
|
|
queue.Add(new UploadBatch { Id = Guid.CreateVersion7(), Mode = UploadTargetMode.Sessions },
|
|
Enumerable.Range(0, 5).Select(i => new QueueEntry($"{i}.jpg", 100, DateTime.UtcNow, null, null, null)));
|
|
queue.Items[0].State = UploadItemState.Verified;
|
|
queue.Items[1].State = UploadItemState.Skipped;
|
|
queue.Items[2].State = UploadItemState.Uploading;
|
|
queue.Items[2].BytesSent = 40;
|
|
queue.Items[3].State = UploadItemState.Failed;
|
|
queue.Items[3].Retries = 1;
|
|
|
|
var s = QueueSummary.From(queue.Items);
|
|
Assert.Equal(5, s.Files);
|
|
Assert.Equal(500L, s.Bytes);
|
|
Assert.Equal(2, s.Sent);
|
|
Assert.Equal(2, s.Verified);
|
|
Assert.Equal(1, s.Failed);
|
|
Assert.Equal(1, s.Retries);
|
|
Assert.Equal(240L, s.DoneBytes);
|
|
Assert.Equal(160L, s.RemainingBytes);
|
|
Assert.Equal("2.jpg", s.CurrentFile);
|
|
Assert.Approximately(0.48, s.Progress, 1e-9);
|
|
}
|
|
}
|