Caching tests: the nested cacheless write propagates its refusal; the variant header pin overrides the name beside the reels
Fixes two tests of the previous commit that failed on their own fixtures (the inner call's exception was swallowed in the hook; a variant that shares its base's name is refused). Builds. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
22c87fd530
commit
6353055b72
2 changed files with 10 additions and 15 deletions
|
|
@ -1213,18 +1213,15 @@ namespace GameCult.Caching.Tests
|
|||
{
|
||||
var registry = CultDocumentRegistry.ForTypes(new[] { typeof(TapDoc) });
|
||||
var store = new RoleStore(_path);
|
||||
Exception? inner = null;
|
||||
TapDoc.Hook = () =>
|
||||
{
|
||||
try { store.WriteDocument(new CultRecordKey("inner"), new TapDoc { Name = "inner" }, registry: registry); }
|
||||
catch (Exception error) { inner = error; }
|
||||
};
|
||||
TapDoc.Hook = () => store.WriteDocument(new CultRecordKey("inner"), new TapDoc { Name = "inner" }, registry: registry);
|
||||
|
||||
var outer = Assert.Catch<Exception>(() => store.WriteDocument(new CultRecordKey("outer"), new TapDoc { Name = "outer" }, registry: registry));
|
||||
|
||||
Assert.That(inner, Is.InstanceOf<InvalidOperationException>());
|
||||
Assert.That(inner!.Message, Does.StartWith(ReentryRefusal));
|
||||
Assert.That(Refused(outer), Is.True, "the outer write failed with the getter's exception");
|
||||
Assert.That(Refused(outer), Is.True, "the outer write failed with the inner call's refusal");
|
||||
var refusal = outer!;
|
||||
while (refusal is not InvalidOperationException && refusal.InnerException != null)
|
||||
refusal = refusal.InnerException;
|
||||
Assert.That(refusal.Message, Does.StartWith(ReentryRefusal));
|
||||
Assert.That(File.Exists(_path), Is.False);
|
||||
Assert.That(store.Attached, Is.Null);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -930,12 +930,10 @@ namespace GameCult.Caching.Tests
|
|||
cache.Commit(batch =>
|
||||
{
|
||||
batch.Upsert(typeof(IdDeck), EmptyDeck("base"), new CultRecordKey("base"));
|
||||
batch.UpsertVariant(new CultRecordKey("v"), new CultRecordKey("base"), new[]
|
||||
{
|
||||
overridden == "name"
|
||||
? cache.Override<IdDeck>(nameof(IdDeck.Name), "v")
|
||||
: cache.Override<IdDeck>(nameof(IdDeck.Reels), new List<IdReel> { new() { Label = "r", Id = HexA } }),
|
||||
});
|
||||
var name = cache.Override<IdDeck>(nameof(IdDeck.Name), "v");
|
||||
batch.UpsertVariant(new CultRecordKey("v"), new CultRecordKey("base"), overridden == "name"
|
||||
? new[] { name }
|
||||
: new[] { name, cache.Override<IdDeck>(nameof(IdDeck.Reels), new List<IdReel> { new() { Label = "r", Id = HexA } }) });
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue