Files
Chronos/tests/Chronos.App.Tests/Server/UploadHoldTests.cs
T
Alby96andClaude Opus 5.5 2654683a12 fix(workspace): close the phase 5c review findings
Originals are now judged by their bytes, never by the media index: a removal
or clean-up hashes every file under media/originals and deletes it only when
the home holds that SHA-256; every other file, named or not, goes to the
workspace trash. Trash entries are filled under a staging name that Empty
never lists. A ledger can only name files inside exports/.

Jobs follow the workspace: a copy, render or send resolves the folder that
holds its project now (a moved workspace, a retry after a move) and waits
while a move has not switched yet. A clean-up failure after the switch is a
warning that keeps the journal for a later resume; entries that changed
since they were copied are kept, and a same-volume rename refused across
volumes falls back to copy and verify.

Sends map a replayed version by content hash, or go with the project only,
and note an old server that drops provenance. The media index (format 2) and
project file (format 3) refuse older readers while they hold originals.
Metered connections also hold sync downloads and server copies. The editor
gains Send again, the Settings page can resume a stopped move, the disabled
tooltips say why, and unused strings are pruned.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-04 17:32:48 +01:00

64 lines
2.7 KiB
C#

using Chronos.App.Server;
using Chronos.Core.Model;
using Chronos.Data.Archiving.Jobs;
using Chronos.Data.Workspaces;
using Chronos.Testing;
namespace Chronos.App.Tests.Server;
/// <summary>
/// Which jobs "Pause metered transfers" holds (Server.html, phase 5c): uploads, the sync's downloads, and the workspace's copies from and renders
/// sent to a server; never a copy from or a send to this PC's archive.
/// </summary>
public sealed class UploadHoldTests
{
private const string Server = "https://nas.local:8443";
private static readonly Guid SequenceId = Guid.CreateVersion7();
private static readonly Guid ProjectId = Guid.CreateVersion7();
private const string Root = @"C:\Users\me\Chronos\workspace";
private static Job Of(ArchiveJobRequest request) => new()
{
Id = Guid.CreateVersion7(),
Kind = request.Kind,
TargetIds = request.Targets,
TargetLabel = request.Label,
ParametersJson = request.ParametersJson,
State = JobState.Queued,
Created = DateTimeOffset.UtcNow,
};
private static Job Of(JobKind kind, string? parameters = null) => new()
{
Id = Guid.CreateVersion7(),
Kind = kind,
TargetIds = [SequenceId],
ParametersJson = parameters,
State = JobState.Queued,
Created = DateTimeOffset.UtcNow,
};
[Test]
public void TransfersWithAServerAreHeld()
{
Assert.True(UploadHold.Holds(Of(JobKind.UploadCommit)));
// The sync's downloads too: the option's tooltip says "uploads and downloads".
Assert.True(UploadHold.Holds(Of(JobKind.Download)));
Assert.True(UploadHold.Holds(Of(WorkspaceJobs.CopyFromServer(SequenceId, "Harbour", Server, Root, ProjectId))));
Assert.True(UploadHold.Holds(Of(WorkspaceJobs.Send(SequenceId, "Harbour", Root, ProjectId, [], Server))));
Assert.SequenceEqual([JobKind.UploadCommit, JobKind.Download, JobKind.WorkspaceCopy, JobKind.WorkspaceSend], UploadHold.Kinds);
}
[Test]
public void TransfersWithThisPcsLibraryAndOtherJobsAreNot()
{
var sequence = new Sequence { Id = SequenceId, ArchiveId = Guid.CreateVersion7(), Title = "Harbour", Folder = "2026/harbour" };
Assert.False(UploadHold.Holds(Of(WorkspaceJobs.Copy(sequence, Root, ProjectId))));
Assert.False(UploadHold.Holds(Of(WorkspaceJobs.Send(SequenceId, "Harbour", Root, ProjectId, []))));
Assert.False(UploadHold.Holds(Of(JobKind.Render)));
// Parameters that cannot be read are not held: the job fails with its reason.
Assert.False(UploadHold.Holds(Of(JobKind.WorkspaceSend, "{not json")));
Assert.False(UploadHold.Holds(Of(JobKind.WorkspaceCopy)));
}
}