refactor: extract NATS.Server.JetStream.Tests project
Move 225 JetStream-related test files from NATS.Server.Tests into a dedicated NATS.Server.JetStream.Tests project. This includes root-level JetStream*.cs files, storage test files (FileStore, MemStore, StreamStoreContract), and the full JetStream/ subfolder tree (Api, Cluster, Consumers, MirrorSource, Snapshots, Storage, Streams). Updated all namespaces, added InternalsVisibleTo, registered in the solution file, and added the JETSTREAM_INTEGRATION_MATRIX define.
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
using NATS.Server.JetStream.Models;
|
||||
using NATS.Server.JetStream.Storage;
|
||||
|
||||
namespace NATS.Server.JetStream.Tests;
|
||||
|
||||
public class StreamStoreContractTests
|
||||
{
|
||||
[Fact]
|
||||
public async Task Append_increments_sequence_and_updates_state()
|
||||
{
|
||||
var store = new FakeStreamStore();
|
||||
var seq = await store.AppendAsync("foo", "bar"u8.ToArray(), default);
|
||||
|
||||
seq.ShouldBe((ulong)1);
|
||||
(await store.GetStateAsync(default)).Messages.ShouldBe((ulong)1);
|
||||
}
|
||||
|
||||
private sealed class FakeStreamStore : IStreamStore
|
||||
{
|
||||
private ulong _last;
|
||||
|
||||
public ValueTask<ulong> AppendAsync(string subject, ReadOnlyMemory<byte> payload, CancellationToken ct)
|
||||
{
|
||||
_last++;
|
||||
return ValueTask.FromResult(_last);
|
||||
}
|
||||
|
||||
public ValueTask<ApiStreamState> GetStateAsync(CancellationToken ct)
|
||||
=> ValueTask.FromResult(new ApiStreamState { Messages = _last });
|
||||
|
||||
public ValueTask<StoredMessage?> LoadAsync(ulong sequence, CancellationToken ct)
|
||||
=> ValueTask.FromResult<StoredMessage?>(null);
|
||||
|
||||
public ValueTask<StoredMessage?> LoadLastBySubjectAsync(string subject, CancellationToken ct)
|
||||
=> ValueTask.FromResult<StoredMessage?>(null);
|
||||
|
||||
public ValueTask<IReadOnlyList<StoredMessage>> ListAsync(CancellationToken ct)
|
||||
=> ValueTask.FromResult<IReadOnlyList<StoredMessage>>([]);
|
||||
|
||||
public ValueTask<bool> RemoveAsync(ulong sequence, CancellationToken ct)
|
||||
=> ValueTask.FromResult(false);
|
||||
|
||||
public ValueTask PurgeAsync(CancellationToken ct) => ValueTask.CompletedTask;
|
||||
|
||||
public ValueTask<byte[]> CreateSnapshotAsync(CancellationToken ct)
|
||||
=> ValueTask.FromResult(Array.Empty<byte>());
|
||||
|
||||
public ValueTask RestoreSnapshotAsync(ReadOnlyMemory<byte> snapshot, CancellationToken ct)
|
||||
=> ValueTask.CompletedTask;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user