Files
Alby96andClaude Opus 5.5 f2b58522b9
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
refactor!: rename Titano to Chronos and move CI and releases to Gitea (#6)
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>
2026-10-23 12:45:18 +02:00

115 lines
5.3 KiB
C#

using System.IO;
using Chronos.Setup.Engine;
using Chronos.Testing;
namespace Chronos.App.Tests.Setup;
/// <summary>
/// "Remove my data" covers only the programs being removed (SRS-05): the desktop app and the Uploader share
/// %LOCALAPPDATA%\Chronos and its logs folder, and uninstalling one product never deletes what another still uses.
/// </summary>
public sealed class UserDataPlanTests(TestContext context)
{
[Test]
public void TheDesktopAppsPlanLeavesTheUploadersFiles()
{
var folder = SampleFolder();
var plan = UserDataPlan.Measure(folder, Owners(UserDataOwners.Chronos));
Assert.SequenceEqual(
["backups", "cache", "chronos.db", "logs" + Path.DirectorySeparatorChar + "chronos-20261012.log", "settings.json"],
plan.Entries.Select(e => e.Name).Order(StringComparer.Ordinal));
Assert.Equal(4000L + 3000 + 300 + 20 + 100, plan.TotalBytes);
plan.Remove();
Assert.SequenceEqual(
["logs" + Path.DirectorySeparatorChar + "uploader-20261012.log", "uploader-queue.json", "uploader.json"],
Directory.EnumerateFiles(folder, "*", SearchOption.AllDirectories).Select(f => Path.GetRelativePath(folder, f)).Order(StringComparer.Ordinal));
Assert.False(Directory.Exists(Path.Combine(folder, "cache")));
}
[Test]
public void TheUploadersPlanLeavesTheDesktopAppsFilesAndEmptiedFoldersGo()
{
var folder = SampleFolder();
var plan = UserDataPlan.Measure(folder, Owners(UserDataOwners.Uploader));
Assert.SequenceEqual(
["logs" + Path.DirectorySeparatorChar + "uploader-20261012.log", "uploader-queue.json", "uploader.json"],
plan.Entries.Select(e => e.Name).Order(StringComparer.Ordinal));
plan.Remove();
Assert.True(File.Exists(Path.Combine(folder, "chronos.db")));
Assert.True(File.Exists(Path.Combine(folder, "logs", "chronos-20261012.log")));
Assert.FileMissing(Path.Combine(folder, "uploader.json"));
Assert.FileMissing(Path.Combine(folder, "logs", "uploader-20261012.log"));
// Once the desktop app's data goes too, nothing is left of the folder.
UserDataPlan.Measure(folder, Owners(UserDataOwners.Chronos)).Remove();
Assert.False(Directory.Exists(folder));
}
[Test]
public void BothProgramsDataIsTheWholeFolderAndNoOwnerIsAnEmptyPlan()
{
var folder = SampleFolder();
var whole = UserDataPlan.Measure(folder, UserDataOwners.All);
Assert.SequenceEqual(
["backups", "cache", "chronos.db", "logs", "settings.json", "uploader-queue.json", "uploader.json"],
whole.Entries.Select(e => e.Name).Order(StringComparer.Ordinal));
Assert.Empty(UserDataPlan.Measure(folder, Owners()).Entries);
whole.Remove();
Assert.False(Directory.Exists(folder));
}
[Test]
public void AProductRemovesTheDataOfItsProgramsThatNoOtherInstalledProductHas()
{
string[] chronos = ["Chronos", "Uploader", "Server"];
string[] uploader = ["Uploader"];
Assert.SequenceEqual(["Chronos", "Uploader"], UserDataOwners.Removable(chronos, []).Order(StringComparer.Ordinal));
Assert.SequenceEqual(["Chronos"], UserDataOwners.Removable(chronos, [uploader]).Order(StringComparer.Ordinal));
Assert.Empty(UserDataOwners.Removable(uploader, [chronos]));
Assert.SequenceEqual(["Uploader"], UserDataOwners.Removable(uploader, [["chronos"]]));
// Chronos Server keeps its data elsewhere: a Server-only product removes nothing here.
Assert.Empty(UserDataOwners.Removable(["Server"], []));
}
[Test]
public void AnInstallationThatCannotBeReadNowKeepsEveryProgramsData()
{
string[] chronos = ["Chronos", "Uploader", "Server"];
var uploader = new InstallLog { Product = "Chronos Uploader", Version = "1.0.0", Components = ["Uploader"] };
Assert.SequenceEqual(["Chronos"], UserDataOwners.RemovableBeside(chronos, [new OtherInstall(@"D:\Chronos Uploader", uploader)]).Order(StringComparer.Ordinal));
// Its drive is offline, its folder is gone or its log is damaged: it may still use the desktop app's index.
Assert.Empty(UserDataOwners.RemovableBeside(chronos, [new OtherInstall(@"E:\Chronos Uploader", null)]));
Assert.Empty(UserDataOwners.RemovableBeside(chronos, [new OtherInstall(null, null)]));
}
private static HashSet<string> Owners(params string[] owners) => new(owners, StringComparer.OrdinalIgnoreCase);
private string SampleFolder()
{
var folder = Path.Combine(context.CreateTempDirectory("userdata"), "Chronos");
Write(folder, "chronos.db", 4000);
Write(folder, "settings.json", 20);
Write(folder, Path.Combine("cache", "proxies", "a.jpg"), 3000);
Write(folder, Path.Combine("backups", "chronos-1.db"), 100);
Write(folder, Path.Combine("logs", "chronos-20261012.log"), 300);
Write(folder, Path.Combine("logs", "uploader-20261012.log"), 200);
Write(folder, "uploader.json", 10);
Write(folder, "uploader-queue.json", 50);
return folder;
}
private static void Write(string folder, string relative, int bytes)
{
var path = Path.Combine(folder, relative);
Directory.CreateDirectory(Path.GetDirectoryName(path)!);
File.WriteAllBytes(path, new byte[bytes]);
}
}