From 6353055b72fdb06f89b2bfa617467a326d67c14b Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sun, 25 Oct 2026 20:14:38 +0100 Subject: [PATCH] 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 --- .../CachelessSingleFileTests.cs | 15 ++++++--------- tests/GameCult.Caching.Tests/ElementIdTests.cs | 10 ++++------ 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/tests/GameCult.Caching.Tests/CachelessSingleFileTests.cs b/tests/GameCult.Caching.Tests/CachelessSingleFileTests.cs index 67d59a5b..a3c5af78 100644 --- a/tests/GameCult.Caching.Tests/CachelessSingleFileTests.cs +++ b/tests/GameCult.Caching.Tests/CachelessSingleFileTests.cs @@ -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(() => store.WriteDocument(new CultRecordKey("outer"), new TapDoc { Name = "outer" }, registry: registry)); - Assert.That(inner, Is.InstanceOf()); - 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); } diff --git a/tests/GameCult.Caching.Tests/ElementIdTests.cs b/tests/GameCult.Caching.Tests/ElementIdTests.cs index 41af34fb..db2fd193 100644 --- a/tests/GameCult.Caching.Tests/ElementIdTests.cs +++ b/tests/GameCult.Caching.Tests/ElementIdTests.cs @@ -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(nameof(IdDeck.Name), "v") - : cache.Override(nameof(IdDeck.Reels), new List { new() { Label = "r", Id = HexA } }), - }); + var name = cache.Override(nameof(IdDeck.Name), "v"); + batch.UpsertVariant(new CultRecordKey("v"), new CultRecordKey("base"), overridden == "name" + ? new[] { name } + : new[] { name, cache.Override(nameof(IdDeck.Reels), new List { new() { Label = "r", Id = HexA } }) }); }); }