CI / Build and test (pull_request) Failing after 2m3s
CI / PostgreSQL 16 integration (pull_request) Skipped
CI / PostgreSQL 17 integration (pull_request) Skipped
CI / Docker image (pull_request) Skipped
CI / Windows tests and installer (pull_request) Skipped
CI / YAML check (pull_request) Successful in 4s
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. 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) and pe-check. 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>
104 lines
4.3 KiB
C#
104 lines
4.3 KiB
C#
using Chronos.Core.Packaging;
|
|
using Chronos.Testing;
|
|
|
|
namespace Chronos.Core.Tests.Packaging;
|
|
|
|
public sealed class InstallTransactionTests(TestContext context)
|
|
{
|
|
[Test]
|
|
public void CommitReplacesFilesAndCleansUp()
|
|
{
|
|
var target = context.CreateTempDirectory();
|
|
File.WriteAllText(Path.Combine(target, "Chronos.exe"), "old");
|
|
File.WriteAllText(Path.Combine(target, "user-notes.txt"), "keep");
|
|
|
|
using (var tx = new InstallTransaction(target))
|
|
{
|
|
Write(tx.StagingDirectory, "Chronos.exe", "new");
|
|
Write(tx.StagingDirectory, "lib/new.dll", "dll");
|
|
tx.Commit(["Chronos.exe", "lib/new.dll"]);
|
|
}
|
|
|
|
Assert.Equal("new", File.ReadAllText(Path.Combine(target, "Chronos.exe")));
|
|
Assert.Equal("dll", File.ReadAllText(Path.Combine(target, "lib", "new.dll")));
|
|
Assert.Equal("keep", File.ReadAllText(Path.Combine(target, "user-notes.txt")));
|
|
Assert.Empty(Directory.GetDirectories(target, ".setup-*"));
|
|
}
|
|
|
|
[Test]
|
|
public void FailedCommitRestoresThePreviousInstall()
|
|
{
|
|
var target = context.CreateTempDirectory();
|
|
File.WriteAllText(Path.Combine(target, "Chronos.exe"), "old");
|
|
// A folder where the new version has a file makes the second move fail.
|
|
Directory.CreateDirectory(Path.Combine(target, "blocked"));
|
|
File.WriteAllText(Path.Combine(target, "blocked", "inside.txt"), "x");
|
|
|
|
using (var tx = new InstallTransaction(target))
|
|
{
|
|
Write(tx.StagingDirectory, "Chronos.exe", "new");
|
|
Write(tx.StagingDirectory, "added.dll", "added");
|
|
Write(tx.StagingDirectory, "blocked", "file");
|
|
// Linux reports IOException, Windows UnauthorizedAccessException for a file moved onto a folder.
|
|
var ex = Assert.Throws<Exception>(() => tx.Commit(["Chronos.exe", "added.dll", "blocked"]));
|
|
Assert.True(ex is IOException or UnauthorizedAccessException, ex.GetType().Name);
|
|
}
|
|
|
|
Assert.Equal("old", File.ReadAllText(Path.Combine(target, "Chronos.exe")));
|
|
Assert.FileMissing(Path.Combine(target, "added.dll"));
|
|
Assert.Equal("x", File.ReadAllText(Path.Combine(target, "blocked", "inside.txt")));
|
|
Assert.Empty(Directory.GetDirectories(target, ".setup-*"));
|
|
}
|
|
|
|
[Test]
|
|
public void StaleStagingFoldersFromAnInterruptedRunAreRemoved()
|
|
{
|
|
var target = context.CreateTempDirectory();
|
|
Directory.CreateDirectory(Path.Combine(target, ".setup-staging-deadbeef", "sub"));
|
|
Directory.CreateDirectory(Path.Combine(target, ".setup-other"));
|
|
using (new InstallTransaction(target))
|
|
{
|
|
}
|
|
Assert.False(Directory.Exists(Path.Combine(target, ".setup-staging-deadbeef")));
|
|
Assert.True(Directory.Exists(Path.Combine(target, ".setup-other")));
|
|
}
|
|
|
|
[Test]
|
|
public void RemoveDeletesOnlyLoggedFilesAndPrunesEmptyFolders()
|
|
{
|
|
var root = context.CreateTempDirectory();
|
|
Write(root, "Chronos.exe", "a");
|
|
Write(root, "lib/x/y.dll", "b");
|
|
Write(root, "lib/keep.txt", "user");
|
|
|
|
var failed = InstalledFiles.Remove(root, ["Chronos.exe", "lib/x/y.dll", "already-gone.dll"], removeEmptyRoot: true);
|
|
|
|
Assert.Empty(failed);
|
|
Assert.FileMissing(Path.Combine(root, "Chronos.exe"));
|
|
Assert.False(Directory.Exists(Path.Combine(root, "lib", "x")));
|
|
Assert.Equal("user", File.ReadAllText(Path.Combine(root, "lib", "keep.txt")));
|
|
Assert.True(Directory.Exists(root), "root keeps unlisted files");
|
|
|
|
InstalledFiles.Remove(root, ["lib/keep.txt"], removeEmptyRoot: true);
|
|
Assert.False(Directory.Exists(root));
|
|
}
|
|
|
|
[Test]
|
|
public void RemoveRefusesPathsOutsideTheRoot()
|
|
{
|
|
var parent = context.CreateTempDirectory();
|
|
var root = Path.Combine(parent, "install");
|
|
Directory.CreateDirectory(root);
|
|
Write(parent, "outside.txt", "precious");
|
|
Assert.Throws<PayloadException>(() => InstalledFiles.Remove(root, ["../outside.txt"]));
|
|
Assert.FileExists(Path.Combine(parent, "outside.txt"));
|
|
}
|
|
|
|
private static void Write(string root, string relative, string content)
|
|
{
|
|
var path = Path.Combine(root, relative.Replace('/', Path.DirectorySeparatorChar));
|
|
Directory.CreateDirectory(Path.GetDirectoryName(path)!);
|
|
File.WriteAllText(path, content);
|
|
}
|
|
}
|