Files
Chronos/tests/Chronos.Core.Tests/Project/ProjectBundleTests.cs
T
Alby96andClaude Opus 5.5 5f27a86406
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
refactor!: rename Titano to Chronos and move CI and releases to Gitea
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>
2026-10-23 11:34:48 +02:00

105 lines
5.0 KiB
C#

using Chronos.Core.Project;
using Chronos.Testing;
namespace Chronos.Core.Tests.Project;
/// <summary>The <c>.chronos</c> project file (BRIEF §18): a sequence reference plus the settings to open it with.</summary>
public sealed class ProjectBundleTests(TestContext context)
{
private static readonly Guid ArchiveId = Guid.Parse("0192a4c1-7b3e-7cc0-8a51-2f9d0e6b1a01");
private static readonly Guid SequenceId = Guid.Parse("0192a4c1-7b3e-7cc0-8a51-2f9d0e6b1a02");
[Test]
public void ARoundTripKeepsTheReferenceAndTheSettings()
{
var bundle = Sample();
var path = Path.Combine(context.CreateTempDirectory("bundle"), ProjectBundle.FileNameFor("Harbour sunset"));
bundle.Save(path);
var back = ProjectBundle.Load(path);
Assert.Equal(bundle.Archive, back.Archive);
Assert.Equal(bundle.Sequence, back.Sequence);
Assert.Equal(bundle.Saved, back.Saved);
Assert.Equal(bundle.Project.ToJson(), back.Project.ToJson());
Assert.Equal(0.8, back.Project.Exposure.DeflickerStrength.Resolve(1.0));
Assert.SequenceEqual([3, 7], back.Project.ExcludedFrames);
var json = File.ReadAllText(path);
Assert.Contains("\"format\": \"chronos-project\"", json);
Assert.Contains("\"formatVersion\": 1", json);
}
[Test]
public void OtherFilesAreRefusedAsNotProjectFiles()
{
Assert.Throws<InvalidDataException>(() => ProjectBundle.Parse("not json"));
Assert.Throws<InvalidDataException>(() => ProjectBundle.Parse("[1, 2]"));
// The archive's own meta files are JSON too, but not project files.
Assert.Throws<InvalidDataException>(() => ProjectBundle.Parse("""{ "schemaVersion": 1, "id": "0192a4c1-7b3e-7cc0-8a51-2f9d0e6b1a01" }"""));
var json = Sample().ToJson();
Assert.Throws<InvalidDataException>(() => ProjectBundle.Parse(json.Replace("\"formatVersion\": 1", "\"formatVersion\": 2", StringComparison.Ordinal)));
Assert.Throws<InvalidDataException>(() => ProjectBundle.Parse(json.Replace(SequenceId.ToString(), "not-a-guid", StringComparison.Ordinal)));
Assert.Throws<InvalidDataException>(() => ProjectBundle.Parse(json.Replace("\"version\": 1", "\"version\": 99", StringComparison.Ordinal)));
Assert.Throws<InvalidDataException>(() => ProjectBundle.Parse(json.Replace("\"folder\"", "\"place\"", StringComparison.Ordinal)));
}
[Test]
public void AFileTooLargeToBeAProjectIsNotRead()
{
var path = Path.Combine(context.CreateTempDirectory("bundle"), "huge.chronos");
using (var stream = File.Create(path)) stream.SetLength(ProjectBundle.MaxBytes + 1L);
Assert.Throws<InvalidDataException>(() => ProjectBundle.Load(path));
}
[Test]
public void FramePositionsApplyOnlyToTheFramesTheyWereSavedFor()
{
var bundle = Sample();
var current = new ProjectSettings
{
ExcludedFrames = [1],
HeroFrame = 2,
Camera = new CameraSettings { Keyframes = [new CameraKey(0, 0.5, 0.5, 1, 0)] },
};
Assert.Same(bundle.Project, bundle.ProjectFor(current, frameCount: 3600));
var changed = bundle.ProjectFor(current, frameCount: 3610);
Assert.SequenceEqual([1], changed.ExcludedFrames);
Assert.Equal(2, changed.HeroFrame);
Assert.Same(current.Camera.Keyframes, changed.Camera.Keyframes);
// Everything else comes from the file.
Assert.Equal(0.8, changed.Exposure.DeflickerStrength.Resolve(1.0));
Assert.Equal(bundle.Project.Camera.Crop, changed.Camera.Crop);
}
[Theory]
[Case("Harbour sunset", "Harbour sunset.chronos")]
[Case("Roof: 12/03 \"storm\"?", "Roof_ 12_03 _storm__.chronos")]
[Case("CON", "_CON.chronos")]
[Case(" ", "Chronos.chronos")]
public void TheFileNameComesFromTheTitle(string title, string expected) => Assert.Equal(expected, ProjectBundle.FileNameFor(title));
[Test]
public void SavingNeverReplacesAnEarlierProjectFile()
{
var folder = context.CreateTempDirectory("bundle");
Assert.Equal(Path.Combine(folder, "Harbour sunset.chronos"), ProjectBundle.FreePathIn(folder, "Harbour sunset"));
File.WriteAllText(Path.Combine(folder, "Harbour sunset.chronos"), "{}");
Directory.CreateDirectory(Path.Combine(folder, "Harbour sunset (2).chronos"));
Assert.Equal(Path.Combine(folder, "Harbour sunset (3).chronos"), ProjectBundle.FreePathIn(folder, "Harbour sunset"));
}
private static ProjectBundle Sample() => new(
new BundleArchive(ArchiveId, "Main archive", @"D:\Timelapse"),
new BundleSequence(SequenceId, "2026/2026-09-28 Harbour sunset", "Harbour sunset", 3600),
new ProjectSettings
{
Exposure = new ExposureSettings { DeflickerStrength = new Auto<double>().WithManual(0.8) },
Camera = new CameraSettings { Crop = [0.1, 0.1, 0.9, 0.9], Keyframes = [new CameraKey(120, 0.4, 0.5, 1.2, 0)] },
ExcludedFrames = [3, 7],
HeroFrame = 1800,
},
new DateTimeOffset(2026, 10, 12, 9, 30, 0, TimeSpan.Zero));
}