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>
90 lines
3.1 KiB
C#
90 lines
3.1 KiB
C#
using Chronos.Core.Naming;
|
|
using Chronos.Testing;
|
|
|
|
namespace Chronos.Core.Tests.Naming;
|
|
|
|
public sealed class PathTemplateTests
|
|
{
|
|
private static readonly NamingContext Frame = new()
|
|
{
|
|
CapturedAt = new DateTime(2026, 9, 28, 18, 2, 11, 250),
|
|
SessionStart = new DateTime(2026, 9, 28, 18, 2, 11),
|
|
Session = 2,
|
|
Number = 1,
|
|
NumberInSession = 1,
|
|
CameraMake = "Canon",
|
|
CameraModel = "Canon EOS R5",
|
|
Lens = "RF24-70mm F2.8 L IS USM",
|
|
Iso = 400,
|
|
ExposureTime = 1.0 / 8,
|
|
FNumber = 8,
|
|
OriginalName = "IMG_0001",
|
|
Extension = "CR2",
|
|
Title = "Harbour sunset",
|
|
};
|
|
|
|
[Test]
|
|
public void DefaultTemplatesMatchTheBriefExample()
|
|
{
|
|
Assert.Equal("2026/2026-09-28 Canon EOS R5", PathTemplate.Parse(TemplateDefaults.Folder).ExpandFolder(Frame));
|
|
Assert.Equal("2026-09-28_18-02-11_0001.CR2", PathTemplate.Parse(TemplateDefaults.File).ExpandFile(Frame));
|
|
}
|
|
|
|
[Theory]
|
|
[Case("{n:000000}", "000001.CR2")]
|
|
[Case("{date:yyyyMMdd}_{name}", "20260928_IMG_0001.CR2")]
|
|
[Case("{iso}_{shutter}_{aperture}", "400_1-8_f8.CR2")]
|
|
[Case("{name}.{ext}", "IMG_0001.CR2")]
|
|
[Case("{{literal}}_{n}", "{literal}_0001.CR2")]
|
|
[Case("{session}-{nsession:00}", "2-01.CR2")]
|
|
public void FileTokens(string template, string expected) =>
|
|
Assert.Equal(expected, PathTemplate.Parse(template).ExpandFile(Frame));
|
|
|
|
[Test]
|
|
public void IllegalCharactersAreReplaced()
|
|
{
|
|
var context = Frame with { Title = "a:b*c?<d>|e\"f" };
|
|
Assert.Equal("a_b_c__d__e_f.CR2", PathTemplate.Parse("{title}").ExpandFile(context));
|
|
}
|
|
|
|
[Test]
|
|
public void TokenValuesNeverCreateFolders()
|
|
{
|
|
var context = Frame with { Lens = "18/55 mm" };
|
|
Assert.Equal("2026/18-55 mm", PathTemplate.Parse("{year}/{lens}").ExpandFolder(context));
|
|
}
|
|
|
|
[Test]
|
|
public void ReservedWindowsNamesAreEscaped() =>
|
|
Assert.Equal("_CON.CR2", PathTemplate.Parse("{title}").ExpandFile(Frame with { Title = "CON" }));
|
|
|
|
[Test]
|
|
public void ErrorsCarryPositionAndToken()
|
|
{
|
|
var t = PathTemplate.Parse("{date}_{bogus}_{n");
|
|
Assert.False(t.IsValid);
|
|
Assert.Contains(new TemplateError(7, "UnknownToken", "bogus"), t.Errors);
|
|
Assert.Contains(t.Errors, e => e.Code == "UnclosedBrace");
|
|
}
|
|
|
|
[Test]
|
|
public void EmptyExpansionFallsBackToOriginalName() =>
|
|
Assert.Equal("IMG_0001.CR2", PathTemplate.Parse("{title}").ExpandFile(Frame with { Title = null }));
|
|
|
|
[Theory]
|
|
[Case("NIKON CORPORATION", "NIKON Z 8", "Nikon Z 8")]
|
|
[Case("SONY", "ILCE-7M4", "SONY ILCE-7M4")]
|
|
[Case("Canon", "Canon EOS R5", "Canon EOS R5")]
|
|
[Case(null, "HERO12 Black", "HERO12 Black")]
|
|
public void CameraNameAvoidsDuplicatedBrand(string? make, string model, string expected) =>
|
|
Assert.Equal(expected, PathTemplate.CameraName(make, model));
|
|
|
|
[Test]
|
|
public void ShutterFormatting()
|
|
{
|
|
Assert.Equal("1-250", PathTemplate.Shutter(0.004));
|
|
Assert.Equal("2s", PathTemplate.Shutter(2));
|
|
Assert.Equal(string.Empty, PathTemplate.Shutter(null));
|
|
}
|
|
}
|