using NATS.Server.JetStream.Cluster;
using NATS.Server.JetStream.Models;

namespace NATS.Server.JetStream.Tests;

public class JetStreamClusterGovernanceRuntimeParityTests
{
    [Fact]
    public async Task Jetstream_cluster_governance_applies_consensus_backed_placement()
    {
        var meta = new JetStreamMetaGroup(3);
        await meta.ProposeCreateStreamAsync(new StreamConfig
        {
            Name = "ORDERS",
            Subjects = ["orders.*"],
        }, default);

        var planner = new AssetPlacementPlanner(3);
        var placement = planner.PlanReplicas(2);
        var replicas = new StreamReplicaGroup("ORDERS", 1);
        await replicas.ApplyPlacementAsync(placement, default);

        meta.GetState().Streams.ShouldContain("ORDERS");
        replicas.Nodes.Count.ShouldBe(2);
    }
}
