Merge branch 'review2-p5a-fix2-workspace' into review2-p5a-int2
# Conflicts: # src/Chronos.Data/Workspaces/WorkspaceSync.cs
This commit is contained in:
commit
775deda0f4
18 files changed
+641
-86
No files matched your search
@@ -1,7 +1,9 @@
|
||||
using System.IO;
|
||||
using Chronos.App.Editor;
|
||||
using Chronos.App.Infrastructure;
|
||||
using Chronos.App.Workspace;
|
||||
using Chronos.Core.Imaging;
|
||||
using Chronos.Core.Imaging.Decoders;
|
||||
using Chronos.Core.Localization;
|
||||
using Chronos.Core.Model;
|
||||
using Chronos.Core.Project;
|
||||
@@ -64,6 +66,26 @@ public sealed class WorkspaceEditorTests(TestContext context)
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task AProjectASyncKeepsBusyOpensOnceItIsFree()
|
||||
{
|
||||
await using var bed = await WorkspaceTestBed.CreateAsync(context, frames: 3);
|
||||
var host = bed.Host();
|
||||
var projectId = await bed.CheckoutAsync(host);
|
||||
var impatient = new WorkspaceSync(host.Store, "Chronos test") { LockWait = TimeSpan.FromMilliseconds(200) };
|
||||
var source = new WorkspaceSequenceSource(impatient, projectId, bed.Db, DecoderFactory.CreateClient(null), bed.Engine);
|
||||
await using (source)
|
||||
{
|
||||
// A long sync or copy holds the project: the editor says so in words, and nothing was read.
|
||||
using (await host.Store.Find(projectId)!.LockAsync(TimeSpan.FromSeconds(TestTiming.Budget(5)), bed.Ct))
|
||||
{
|
||||
var busy = await Assert.ThrowsAsync<EditorException>(() => source.LoadAsync(bed.Ct));
|
||||
Assert.Equal(Loc.L("Errors.Workspace.Busy"), busy.Message);
|
||||
}
|
||||
Assert.Equal(3, (await source.LoadAsync(bed.Ct)).Frames.Count);
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task SaveVersionSendsItAndTheLibraryTakesMain()
|
||||
{
|
||||
|
||||
@@ -5,7 +5,9 @@ using Chronos.App.Workspace;
|
||||
using Chronos.Core.Localization;
|
||||
using Chronos.Core.Model;
|
||||
using Chronos.Core.Project;
|
||||
using Chronos.Data.Projects;
|
||||
using Chronos.Data.Sync;
|
||||
using Chronos.Ui.Controls;
|
||||
using Chronos.Data.Workspaces;
|
||||
using Chronos.Testing;
|
||||
|
||||
@@ -258,6 +260,25 @@ public sealed class WorkspaceMenuTests(TestContext context)
|
||||
Assert.Equal((WorkspaceState.Behind, 2), (ProjectMenuViewModel.WithLocal(behind, edited).State, ProjectMenuViewModel.WithLocal(behind, edited).Behind));
|
||||
Assert.Equal(WorkspaceState.Modified, ProjectMenuViewModel.WithLocal(behind, edited with { Base = basis with { VersionId = Guid.NewGuid() } }).State,
|
||||
"a base that moved since says nothing of how far the library is ahead");
|
||||
// A version saved here that cannot be read outranks what the library said.
|
||||
Assert.Equal(WorkspaceState.Damaged, ProjectMenuViewModel.WithLocal(behind, edited with { Damaged = 1 }).State);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ADamagedVersionAndOneTooLargeReadAsSuch()
|
||||
{
|
||||
var damaged = new WorkspaceStatus(WorkspaceState.Damaged, false, 1, 0, false, false, false, null, null, null) { Damaged = 1 };
|
||||
Assert.Equal((Loc.L("Editor.Workspace.State.Damaged"), StatusKind.Error), (WorkspaceText.State(damaged), WorkspaceText.Kind(damaged)));
|
||||
Assert.Equal(Loc.L("Tooltips.Editor.Workspace.State.Damaged"), WorkspaceText.StateToolTip(damaged));
|
||||
Assert.Equal(Loc.L("Errors.Workspace.Damaged"), WorkspaceText.Failure(new InvalidDataException("a version file cannot be read")));
|
||||
|
||||
// Too large: a version saved here (refused before it was written) and one the library refused say the same, with the limit.
|
||||
var tooLarge = Loc.L("Errors.Workspace.VersionTooLarge", ProjectSidecars.MaxVersionBytes >> 20);
|
||||
Assert.Contains("64", tooLarge);
|
||||
Assert.Equal(tooLarge, WorkspaceText.Failure(new ProjectVersionTooLargeException("over the limit")));
|
||||
Assert.Equal(tooLarge, WorkspaceText.Failure(new WorkspaceSyncException(PushOutcome.TooLarge, "over the limit")));
|
||||
Assert.Equal(tooLarge, Chronos.App.Shell.ErrorText.For(new ProjectVersionTooLargeException("over the limit")));
|
||||
Assert.Equal(Loc.L("Errors.Workspace.Refused"), WorkspaceText.Failure(new WorkspaceSyncException(PushOutcome.Invalid, "not this project's")));
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
||||
Reference in new issue
Block a user