UniqueIndexTests: pin the delete's Forgot and the foreign record's version in the moved-store gate
All checks were successful
CultMesh portability and performance / ubuntu-latest reactive semantics and leases (pull_request) Successful in 30m11s
All checks were successful
CultMesh portability and performance / ubuntu-latest reactive semantics and leases (pull_request) Successful in 30m11s
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
dc7be51a11
commit
4c7354be79
1 changed files with 43 additions and 0 deletions
|
|
@ -335,6 +335,49 @@ namespace GameCult.Caching.Tests
|
|||
Assert.That(second.Commit(batch => batch.Upsert(typeof(UqItem), Item("x"), Key("c"))), Is.True, "only this cache wrote since it last read");
|
||||
}
|
||||
|
||||
// A record this cache removed is gone from what it last read: its next indexed write is judged against the store after the
|
||||
// removal, not refused for a record it deleted itself.
|
||||
[Test]
|
||||
public void ADeleteIsRecordedSoTheNextIndexedWriteIsJudgedAgainstTheStoreAfterIt([Values] StoreKind kind)
|
||||
{
|
||||
var path = PathOf("items.cc");
|
||||
using var seed = Open(path, kind);
|
||||
seed.Commit(batch =>
|
||||
{
|
||||
batch.Upsert(typeof(UqItem), Item("one"), Key("a"));
|
||||
batch.Upsert(typeof(UqItem), Item("two"), Key("b"));
|
||||
});
|
||||
using var cache = Open(path, kind);
|
||||
Assert.That(cache.Commit(batch => batch.Remove(Key("b"))), Is.True);
|
||||
|
||||
Assert.That(cache.Commit(batch => batch.Upsert(typeof(UqItem), Item("three"), Key("c"))), Is.True,
|
||||
"nothing but this cache's own delete moved the store");
|
||||
using var reopened = Open(path, kind);
|
||||
Assert.That(reopened.Get(Key("b")), Is.Null);
|
||||
Assert.That(reopened.Get(Key("c")), Is.Not.Null);
|
||||
}
|
||||
|
||||
// A record of a type this cache does not define is part of the store it last read: unchanged, it never refuses an indexed
|
||||
// write; changed by another writer, it does.
|
||||
[Test]
|
||||
public void AForeignTypedRecordIsReadWithTheStoreAndRefusesAnIndexedWriteOnlyWhenItMoves([Values] StoreKind kind)
|
||||
{
|
||||
var path = PathOf("items.cc");
|
||||
using var seed = Open(path, kind);
|
||||
seed.Commit(batch =>
|
||||
{
|
||||
batch.Upsert(typeof(UqItem), Item("one"), Key("a"));
|
||||
batch.Upsert(typeof(UqTagged), new UqTagged { Kind = "x" }, Key("tag"));
|
||||
});
|
||||
using var narrow = Open(path, kind, CultDocumentRegistry.ForTypes(new[] { typeof(UqItem) }));
|
||||
Assert.That(narrow.Commit(batch => batch.Upsert(typeof(UqItem), Item("two"), Key("b"))), Is.True,
|
||||
"the foreign record has not moved since this cache read the store");
|
||||
|
||||
seed.Commit(batch => batch.Upsert(typeof(UqTagged), new UqTagged { Kind = "y" }, Key("tag")));
|
||||
Assert.Throws<CultWriteConflictException>(
|
||||
() => narrow.Commit(batch => batch.Upsert(typeof(UqItem), Item("three"), Key("c"))));
|
||||
}
|
||||
|
||||
// A conflict costs Update an attempt, not an error: it applies again to what the store holds and lands.
|
||||
[Test]
|
||||
public void AnUpdateOnAMovedDirectoryStoreRetriesAndLands()
|
||||
|
|
|
|||
Loading…
Reference in a new issue