batch36 task4 stream mirror lifecycle helpers

This commit is contained in:
Joseph Doherty
2026-02-28 23:02:51 -05:00
parent 3c974fbe55
commit 856cd17554
5 changed files with 315 additions and 14 deletions

View File

@@ -123,6 +123,44 @@ public sealed class StreamLifecycleGroupBTests
jsa.SubjectsOverlap(["orders.created"], ownAssignment: null).ShouldBeTrue();
}
[Fact]
public void GroupCHelpers_GetCfgNameAndIsMirror_ReturnExpectedValues()
{
var mirrorCfg = new StreamConfig
{
Name = "MIRROR",
Storage = StorageType.MemoryStorage,
Mirror = new StreamSource { Name = "ORIGIN" },
};
var stream = CreateStream(mirrorCfg);
stream.GetCfgName().ShouldBe("MIRROR");
stream.IsMirror().ShouldBeTrue();
stream.MirrorInfo().ShouldBeNull();
}
[Fact]
public void GroupCHelpers_SourceInfoAndBackoff_Behave()
{
var stream = CreateStream();
var info = new StreamSourceInfo
{
Name = "SRC",
FilterSubject = "orders.*",
Lag = 10,
Error = "x",
};
var cloned = stream.SourceInfo(info);
cloned.ShouldNotBeNull();
cloned!.Name.ShouldBe("SRC");
cloned.FilterSubject.ShouldBe("orders.*");
NatsStream.CalculateRetryBackoff(1).ShouldBeGreaterThan(TimeSpan.Zero);
NatsStream.CalculateRetryBackoff(1000).ShouldBe(TimeSpan.FromMinutes(2));
}
private static NatsStream CreateStream(StreamConfig? cfg = null)
{
cfg ??= new StreamConfig { Name = "ORDERS", Subjects = ["orders.*"], Storage = StorageType.MemoryStorage };