feat: single setup, mass-pass progress, per-server homes, Desktop shares its library (owner review 5, v1.1.0) (#68)
CI / Build and test (push) Successful in 11m36s
CI / Windows tests and installer (push) Skipped
CI / YAML check (push) Successful in 12s
Release / Build, test and publish (push) Successful in 14m56s
CI / PostgreSQL 16 integration (push) Successful in 10m11s
CI / PostgreSQL 17 integration (push) Successful in 10m15s
CI / Docker image (push) Successful in 45s
Release / Server image (push) Successful in 4m55s
CI / Build and test (push) Successful in 11m36s
CI / Windows tests and installer (push) Skipped
CI / YAML check (push) Successful in 12s
Release / Build, test and publish (push) Successful in 14m56s
CI / PostgreSQL 16 integration (push) Successful in 10m11s
CI / PostgreSQL 17 integration (push) Successful in 10m15s
CI / Docker image (push) Successful in 45s
Release / Server image (push) Successful in 4m55s
Co-authored-by: Alberto Balbo <alberto.balbo.96@gmail.com>
This commit was merged in pull request #68.
This commit is contained in:
1 parent
988068ee8e
commit
20d64af4a4
793 files changed
+23882
-2096
No files matched your search
@@ -0,0 +1,58 @@
|
||||
using Chronos.Core.IO;
|
||||
using Chronos.Data.Sync;
|
||||
using Chronos.Data.Tests.Homes;
|
||||
using Chronos.Testing;
|
||||
|
||||
namespace Chronos.Data.Tests.Sync;
|
||||
|
||||
/// <summary>Where the proxies of a server's sequence live (owner review 5, #66): its home in the cache, else where an earlier layout left them.</summary>
|
||||
[Category("sync")]
|
||||
public sealed class ProxyCacheTests(TestContext context)
|
||||
{
|
||||
private static readonly Guid Id = Guid.Parse("0192a4c1-7b3e-7cc0-8a51-2f9d0e6b1a01");
|
||||
|
||||
[Test]
|
||||
public void WithoutAServersRootTheLayoutIs10s()
|
||||
{
|
||||
var root = context.CreateTempDirectory("proxies");
|
||||
var remote = Guid.CreateVersion7();
|
||||
var cache = new ProxyCache(root);
|
||||
Assert.Equal(Path.Combine(root, HomeFolders.AddressHash(HomeFixtures.Nas), remote.ToString("N")), cache.Folder(HomeFixtures.Nas, remote));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ANewSequenceGoesToItsServersHomeAndAnOldOneIsReadWhereItIs()
|
||||
{
|
||||
var cacheRoot = context.CreateTempDirectory("cache");
|
||||
var (legacyRoot, servers) = (Path.Combine(cacheRoot, "proxies"), Path.Combine(cacheRoot, "servers"));
|
||||
var identity = new ServerIdentity([new KnownServerKey(Id, [HomeFixtures.Nas])]);
|
||||
var cache = new ProxyCache(legacyRoot, servers, () => identity);
|
||||
var idKey = ServerIdentity.IdKey(Id);
|
||||
|
||||
var fresh = Guid.CreateVersion7();
|
||||
Assert.Equal(Path.Combine(servers, Id.ToString("N"), "proxies", fresh.ToString("N")), cache.Folder(idKey, fresh));
|
||||
Assert.Equal(cache.Folder(idKey, fresh), cache.Folder(HomeFixtures.Nas, fresh), "an alias names the same home");
|
||||
|
||||
// A sequence cached by 1.0 under the address is used where it is until it is moved.
|
||||
var old = Guid.CreateVersion7();
|
||||
var legacy = HomeFixtures.LegacyProxies(cacheRoot, HomeFixtures.Nas, old);
|
||||
Assert.Equal(legacy, cache.Folder(idKey, old));
|
||||
Assert.True(cache.Exists(idKey, old));
|
||||
|
||||
// In the home of the address (sorted before the server announced its id): used there too.
|
||||
var sorted = Guid.CreateVersion7();
|
||||
var byAddress = Path.Combine(servers, HomeFolders.ServerFolder(HomeFixtures.Nas), "proxies", sorted.ToString("N"));
|
||||
Directory.CreateDirectory(byAddress);
|
||||
Assert.Equal(byAddress, cache.Folder(idKey, sorted));
|
||||
|
||||
// Once in its home, that is where it is.
|
||||
var home = Path.Combine(servers, Id.ToString("N"), "proxies", old.ToString("N"));
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(home)!);
|
||||
Directory.Move(legacy, home);
|
||||
Assert.Equal(home, cache.Folder(HomeFixtures.Nas, old));
|
||||
|
||||
// A server known by its address only has an address home.
|
||||
var other = Guid.CreateVersion7();
|
||||
Assert.Equal(Path.Combine(servers, HomeFolders.ServerFolder(HomeFixtures.Other), "proxies", other.ToString("N")), cache.Folder(HomeFixtures.Other, other));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user