Mesh single-file store: tests for dangling link, directory, zero byte, lock, concurrent replace and the older layout; contract sentence
Behavioural tests through Mesh and CultCache for each rule the cut owns, and the persistence contract's single-readability paragraph states that one runtime has one reader, lock and replace and that only nothing at the path is missing. Not yet run: verification follows in one job. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
9852fa9367
commit
b1ff2dcbce
5 changed files with 370 additions and 10 deletions
|
|
@ -2,6 +2,7 @@ using System;
|
|||
using System.IO;
|
||||
using FluentAssertions;
|
||||
using GameCult.Caching;
|
||||
using GameCult.Caching.MessagePack;
|
||||
using NUnit.Framework;
|
||||
|
||||
#nullable enable
|
||||
|
|
@ -38,6 +39,38 @@ public sealed class CultMeshVariantRefusalTests
|
|||
message.Should().Contain("item:anvil").And.Contain(ItemSchemaId);
|
||||
}
|
||||
|
||||
// The older catalog layout (the content hash at entry slot 5) is a store no C# reader reads: CultMesh refuses it as CultCache
|
||||
// does, on a read and on a raw write, and a refused write leaves the bytes as they were.
|
||||
[TestCase("legacy-catalog-plain.msgpack")]
|
||||
[TestCase("legacy-catalog-extra-slot.msgpack")]
|
||||
[TestCase("legacy-catalog-trailing.msgpack")]
|
||||
public void TheOlderCatalogLayoutIsRefusedByMeshAndCultCacheAlike(string vector)
|
||||
{
|
||||
Refusal(vector).Path.Should().Be(VectorPath(vector));
|
||||
|
||||
var directory = Path.Combine(Path.GetTempPath(), "cultmesh-legacy-layout", Guid.NewGuid().ToString("N"));
|
||||
Directory.CreateDirectory(directory);
|
||||
try
|
||||
{
|
||||
var path = Path.Combine(directory, vector);
|
||||
File.Copy(VectorPath(vector), path);
|
||||
var bytes = File.ReadAllBytes(path);
|
||||
var raw = new CultMeshSingleFileDocumentSchema("raw:schema", "RawSchema", "1");
|
||||
|
||||
Assert.Throws<CultStoreUnreadableException>(() =>
|
||||
CultMesh.WriteSingleFileDocumentPayload(path, new CultRecordKey("item:bellows"), raw, null, new byte[] { 0x90 }))!
|
||||
.Path.Should().Be(path);
|
||||
File.ReadAllBytes(path).Should().Equal(bytes);
|
||||
|
||||
Assert.Throws<CultStoreUnreadableException>(() => CultCacheMessagePack.Create(path, new CultCacheOpenOptions { FlushOnDispose = false, StoreFlushOnDispose = false }))!
|
||||
.Path.Should().Be(path);
|
||||
}
|
||||
finally
|
||||
{
|
||||
Directory.Delete(directory, true);
|
||||
}
|
||||
}
|
||||
|
||||
// A store in the current layout with one catalog slot malformed is refused as CultCache refuses it.
|
||||
[TestCase("current-catalog-bad-canonical.msgpack")]
|
||||
[TestCase("current-catalog-bad-members.msgpack")]
|
||||
|
|
|
|||
Loading…
Reference in a new issue