Files
Abdullah Atta b0e8840572 api: list sync item collections in one place
The hub's two fetch lists, its push map, the encryption verifier lookup and the account delete/reset lists each named every collection. They now all come from SyncItemCollections on the repository accessor, which also marks the legacy settings collection as deleted but not synced. A test checks every repository is registered.
2026-10-22 13:13:09 +05:00

28 lines
981 B
C#

using Notesnook.API.Repositories;
namespace Notesnook.API.Tests;
public class SyncItemCollectionsTests(TestDatabase db) : IClassFixture<TestDatabase>
{
// sync, push, reset and account deletion all read this list, so a repository missing from it
// would silently be neither synced nor deleted
[Fact]
public void Every_sync_item_repository_is_registered()
{
var accessor = db.CreateScope().Repositories;
var repositories = accessor.GetType().GetProperties()
.Where((p) => p.PropertyType == typeof(SyncItemsRepository))
.Select((p) => p.GetValue(accessor))
.ToHashSet();
Assert.Equal(repositories, accessor.SyncItemCollections.Select((c) => c.Repository).ToHashSet<object?>());
}
[Fact]
public void Relations_sync_last()
{
var accessor = db.CreateScope().Repositories;
Assert.Equal("relation", accessor.SyncItemCollections.Last((c) => c.Type != null).Type);
}
}