test: lock FileStore optimization boundaries

This commit is contained in:
Joseph Doherty
2026-03-13 10:29:10 -04:00
parent 655ca30e0b
commit 5674853628
3 changed files with 87 additions and 0 deletions

View File

@@ -15,4 +15,22 @@ public class JetStreamStoreIndexTests
var last = await store.LoadLastBySubjectAsync("orders.created", default);
last!.Payload.Span.SequenceEqual("3"u8).ShouldBeTrue();
}
[Fact]
public async Task FileStore_trim_to_zero_preserves_high_water_mark_for_empty_state()
{
var dir = Directory.CreateTempSubdirectory();
await using var store = new FileStore(new FileStoreOptions { Directory = dir.FullName });
await store.AppendAsync("orders.created", "1"u8.ToArray(), default);
await store.AppendAsync("orders.updated", "2"u8.ToArray(), default);
await store.AppendAsync("orders.created", "3"u8.ToArray(), default);
store.TrimToMaxMessages(0);
var state = await store.GetStateAsync(default);
state.Messages.ShouldBe(0UL);
state.LastSeq.ShouldBe(3UL);
state.FirstSeq.ShouldBe(4UL);
}
}