From 100a51e18635d1c7ae8e5b86c81cdfe4c077165a Mon Sep 17 00:00:00 2001 From: Libby Date: Thu, 12 Nov 2026 22:54:08 +0000 Subject: [PATCH] tests: a manifest link put at a directory store after open leaves no records folder or lease Co-Authored-By: Claude Sonnet 5.5 --- .../StoreLinkRefusalTests.cs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/GameCult.Caching.Tests/StoreLinkRefusalTests.cs b/tests/GameCult.Caching.Tests/StoreLinkRefusalTests.cs index 1de99237..4444b176 100644 --- a/tests/GameCult.Caching.Tests/StoreLinkRefusalTests.cs +++ b/tests/GameCult.Caching.Tests/StoreLinkRefusalTests.cs @@ -261,6 +261,21 @@ namespace GameCult.Caching.Tests Assert.That(Directory.GetFileSystemEntries(link + ".records").OrderBy(entry => entry), Is.EqualTo(pages), "the refused write left files beside the manifest"); } + // The refusal comes before the records folder or the lease file is made: a store that was never written leaves nothing behind. + [Test] + public void ADirectoryStoreCommitAtAManifestLinkPutThereAfterOpenCreatesNothing() + { + var link = PathOf("link.cc"); + using var cache = OpenDirectory(new DirectoryMessagePackBackingStore(link)); + Link(link, PathOf("unmounted.cc")); + + Assert.Throws(() => + cache.Commit(batch => batch.Upsert(typeof(IdDeck), new IdDeck { Name = "b" }, new CultRecordKey("b")))); + + Assert.That(IsALink(link), "the link was replaced"); + Assert.That(Directory.Exists(link + ".records"), Is.False, "the refused write made the records folder or its lease"); + } + [Test] public void ADirectoryStoreFlushAtALiveManifestLinkIsRefused() {