From dfde61aba38c47d94cf588b47c1e350a97852180 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Tue, 29 Sep 2026 19:59:52 +0200 Subject: [PATCH] C2a test: a preset id and a loaded record holding one mark the store Co-Authored-By: Claude Opus 5.5 --- tests/GameCult.Caching.Tests/ElementIdTests.cs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/GameCult.Caching.Tests/ElementIdTests.cs b/tests/GameCult.Caching.Tests/ElementIdTests.cs index a633fd39..e18276fe 100644 --- a/tests/GameCult.Caching.Tests/ElementIdTests.cs +++ b/tests/GameCult.Caching.Tests/ElementIdTests.cs @@ -691,6 +691,24 @@ namespace GameCult.Caching.Tests Assert.That(HeaderOf(marked), Is.EqualTo("cultcache.store.v3"), "a file already marked on disk stays marked"); } + [Test] + public void AnIdAlreadyThereMarksTheStoreAndSoDoesARecordLoadedHoldingOne() + { + var preset = PathOf("preset.cc"); + using (var cache = Open(preset)) + cache.Commit(batch => batch.Upsert(typeof(IdDeck), new IdDeck { Name = "p", Reels = { new IdReel { Id = HexA } } }, new CultRecordKey("p"))); + Assert.That(HeaderOf(preset), Is.EqualTo("cultcache.store.v3"), "the deck minted nothing, and still holds an id"); + + // The deck reloads holding ids it did not mint; a whole-store flush of a store now holding only that deck and an empty one. + using (var cache = Open(preset)) + { + cache.UpsertAsync(typeof(IdDeck), EmptyDeck("e"), new CultRecordKey("e")).GetAwaiter().GetResult(); + cache.FlushAllBackingStores(); + } + + Assert.That(HeaderOf(preset), Is.EqualTo("cultcache.store.v3"), "a loaded record's ids count"); + } + [Test] public void ADirectoryStoreIsMarkedByTheIdsItWritesAndAnEmptyDeckDoesNotMarkIt() {