CI / Build and test (push) Successful in 13m44s
CI / Windows tests and installer (push) Skipped
CI / YAML check (push) Successful in 16s
Release / Build, test and publish (push) Successful in 26m34s
CI / PostgreSQL 16 integration (push) Failing after 17m36s
CI / PostgreSQL 17 integration (push) Failing after 15m36s
CI / Docker image (push) Successful in 1m12s
Release / Server image (push) Failing after 15s
The same time-lapse on a server and on this PC under different ids, or twice on this PC, is recognised, compared and settled as the owner asked in owner review 6. Matches are found after each sync refresh, through the server's new photo lookup, and after the jobs that change photos. The default is to ask every time. Server › Matches offers: - Keep apart, which is remembered; - Link only and Unlink; - the Compare dialog: photos, details line by line, projects and the plan. Integrate completes both sides. Photos default to Union, projects are copied across, and a losing version goes to the trash only after a hash check. Afterwards new photos move by themselves, and deletions wait for the user. A merge of two local sequences verifies every photo before the other sequence goes to its archive's trash. Upload all local skips suspected matches and flags them. Migration 0012 adds the found_copies and copy_probes tables. Jobs 25 (Integrate) and 26 (MergeSequences) are new, and so are the server capabilities photo-lookup and upload-into. Refs #73 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Alberto Balbo <alberto.balbo.96@gmail.com>
107 lines
5.0 KiB
C#
107 lines
5.0 KiB
C#
using Chronos.Core.Model;
|
|
using Chronos.Data.Jobs;
|
|
using Chronos.Protocol;
|
|
using Chronos.Testing;
|
|
|
|
namespace Chronos.Data.Tests.Jobs;
|
|
|
|
/// <summary>The names the jobs' kinds carry on the wire and in settings (BRIEF §14.6): stable once shipped.</summary>
|
|
[Category("jobs")]
|
|
public sealed class JobWireTests
|
|
{
|
|
[Theory]
|
|
[Case(JobKind.WorkspaceCopy, 20, "workspace-copy")]
|
|
[Case(JobKind.WorkspaceRender, 21, "workspace-render")]
|
|
[Case(JobKind.WorkspaceSend, 22, "workspace-send")]
|
|
[Case(JobKind.WorkspaceMove, 23, "workspace-move")]
|
|
[Case(JobKind.VideoCopy, 24, "video-copy")]
|
|
[Case(JobKind.Integrate, 25, "integrate")]
|
|
[Case(JobKind.MergeSequences, 26, "merge-sequences")]
|
|
public void TheWorkspaceJobsKeepTheirValueAndName(JobKind kind, int value, string name)
|
|
{
|
|
Assert.Equal(value, (int)kind);
|
|
Assert.Equal(name, JobWire.Kind(kind));
|
|
Assert.True(JobWire.TryParseKind(name, out var parsed), name);
|
|
Assert.Equal(kind, parsed);
|
|
}
|
|
|
|
[Test]
|
|
public void EveryKindHasItsOwnName()
|
|
{
|
|
var names = Enum.GetValues<JobKind>().Select(JobWire.Kind).ToList();
|
|
Assert.Equal(names.Count, names.Distinct(StringComparer.Ordinal).Count());
|
|
Assert.False(JobWire.TryParseKind("workspace-teleport", out _));
|
|
}
|
|
|
|
/// <summary>Steps and units are stored and sent by name, appended only: these values and names are pinned once shipped.</summary>
|
|
[Theory]
|
|
[Case(JobStep.None, 0, "none")]
|
|
[Case(JobStep.List, 1, "list")]
|
|
[Case(JobStep.Verify, 4, "verify")]
|
|
[Case(JobStep.CopyPhoto, 11, "copy-photo")]
|
|
[Case(JobStep.CopyOriginal, 13, "copy-original")]
|
|
[Case(JobStep.FollowUps, 22, "follow-ups")]
|
|
[Case(JobStep.Process, 23, "process")]
|
|
[Case(JobStep.Details, 24, "details")]
|
|
[Case(JobStep.Projects, 25, "projects")]
|
|
[Case(JobStep.Trash, 26, "trash")]
|
|
public void StepsKeepTheirValueAndName(JobStep step, int value, string name)
|
|
{
|
|
Assert.Equal(value, (int)step);
|
|
Assert.Equal(name, JobWire.Step(step));
|
|
Assert.True(JobWire.TryParseStep(name, out var parsed), name);
|
|
Assert.Equal(step, parsed);
|
|
}
|
|
|
|
[Test]
|
|
public void EveryStepAndUnitHasItsOwnName()
|
|
{
|
|
var steps = Enum.GetValues<JobStep>().Select(JobWire.Step).ToList();
|
|
Assert.Equal(steps.Count, steps.Distinct(StringComparer.Ordinal).Count());
|
|
Assert.SequenceEqual(["none", "sequence", "folder", "render", "entry", "step"], Enum.GetValues<JobPartUnit>().Select(JobWire.PartUnit));
|
|
Assert.False(JobWire.TryParseStep("teleport", out _));
|
|
Assert.False(JobWire.TryParsePartUnit(null, out _));
|
|
}
|
|
|
|
[Test]
|
|
public void ADetailCrossesTheWireAndBack()
|
|
{
|
|
var detail = new JobDetail(JobStep.CopyOriginal, "2024/2024-09-27 Harbour sunset", 1240, 3600, 12, 340, JobPartUnit.Folder);
|
|
var dto = JobWire.Detail(detail)!;
|
|
Assert.Equal(new JobDetailDto("copy-original", "2024/2024-09-27 Harbour sunset", 1240, 3600, 12, 340, "folder"), dto);
|
|
Assert.Equal(detail, JobWire.FromDto(dto));
|
|
// A unit of none is left out; nothing is none.
|
|
Assert.Null(JobWire.Detail(new JobDetail(JobStep.Backup))!.PartUnit);
|
|
Assert.Null(JobWire.Detail(null));
|
|
Assert.Null(JobWire.FromDto((JobDetailDto?)null));
|
|
|
|
// A newer peer's step or unit reads as none and its counts stay; nonsense counts read as 0.
|
|
Assert.Equal(new JobDetail(JobStep.None, "x", 0, 9, 2, 0), JobWire.FromDto(new JobDetailDto("teleport", "x", -4, 9, 2, -1, "galaxy")));
|
|
Assert.Equal(new JobDetail(JobStep.None), JobWire.FromDto(new JobDetailDto(null!)));
|
|
}
|
|
|
|
[Test]
|
|
public void AnItemIsCutToItsLongestLengthWithoutSplittingACharacter()
|
|
{
|
|
var plain = new string('a', JobDetail.MaxItemLength + 40);
|
|
Assert.Equal(JobDetail.MaxItemLength, new JobDetail(JobStep.Index, plain).Item!.Length);
|
|
// A pair whose high half would be the last kept character goes whole.
|
|
var emoji = new string('a', JobDetail.MaxItemLength - 1) + "\U0001F4F7" + "tail";
|
|
var cut = new JobDetail(JobStep.Index, emoji).Item!;
|
|
Assert.Equal(JobDetail.MaxItemLength - 1, cut.Length);
|
|
Assert.False(char.IsHighSurrogate(cut[^1]));
|
|
Assert.Equal(JobDetail.MaxItemLength, (new JobDetail(JobStep.Index) with { Item = plain }).Item!.Length);
|
|
Assert.Equal(JobDetail.MaxItemLength, JobWire.FromDto(new JobDetailDto("index", plain))!.Item!.Length);
|
|
Assert.Equal("short", new JobDetail(JobStep.Index, "short").Item);
|
|
}
|
|
|
|
[Test]
|
|
public void AServerJobBringsItsDetail()
|
|
{
|
|
var dto = new JobDto(Guid.NewGuid(), "verify", [], "Archive", "paused", "normal", 4, 10, null, null, null, null, 1, null, DateTimeOffset.UtcNow, null, null,
|
|
Detail: new JobDetailDto("verify", "Harbour sunset", 812, 2400, 3, 41, "sequence"));
|
|
Assert.Equal(new JobDetail(JobStep.Verify, "Harbour sunset", 812, 2400, 3, 41, JobPartUnit.Sequence), JobWire.FromDto(dto)!.Detail);
|
|
Assert.Null(JobWire.FromDto(dto with { Detail = null })!.Detail);
|
|
}
|
|
}
|