test: lock FileStore optimization boundaries
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user