feat(audit-log): SiteAuditRetentionOptions (7-day default, clamped 1-90)
RetentionDays clamped [1,90]; PurgeInterval clamped to >= 1 min (Timer spin footgun); 5-min InitialDelay so a daily-recycled node still purges. (PLAN-04 Task 2)
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
using ZB.MOM.WW.ScadaBridge.AuditLog.Site;
|
||||
|
||||
namespace ZB.MOM.WW.ScadaBridge.AuditLog.Tests.Site;
|
||||
|
||||
/// <summary>
|
||||
/// Tests for <see cref="SiteAuditRetentionOptions"/> clamping (PLAN-04 Task 2).
|
||||
/// The resolved knobs guard the daily site retention job against misconfiguration:
|
||||
/// retention days are clamped to [1, 90]; the purge interval is clamped away from
|
||||
/// TimeSpan.Zero (an Akka/Timer spin footgun).
|
||||
/// </summary>
|
||||
public class SiteAuditRetentionOptionsTests
|
||||
{
|
||||
[Theory]
|
||||
[InlineData(0, 1)] // clamp floor
|
||||
[InlineData(7, 7)] // default passthrough
|
||||
[InlineData(365, 90)] // clamp ceiling (spec: min 1, max 90)
|
||||
public void ResolvedRetentionDays_Clamps(int configured, int expected)
|
||||
=> Assert.Equal(expected, new SiteAuditRetentionOptions { RetentionDays = configured }.ResolvedRetentionDays);
|
||||
|
||||
[Fact]
|
||||
public void Defaults_Are_SevenDays_DailyPurge_FiveMinuteInitialDelay()
|
||||
{
|
||||
var o = new SiteAuditRetentionOptions();
|
||||
Assert.Equal(7, o.ResolvedRetentionDays);
|
||||
Assert.Equal(TimeSpan.FromHours(24), o.ResolvedPurgeInterval);
|
||||
Assert.Equal(TimeSpan.FromMinutes(5), o.InitialDelay);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ResolvedPurgeInterval_ClampsZeroToOneMinute()
|
||||
=> Assert.Equal(TimeSpan.FromMinutes(1),
|
||||
new SiteAuditRetentionOptions { PurgeInterval = TimeSpan.Zero }.ResolvedPurgeInterval);
|
||||
}
|
||||
Reference in New Issue
Block a user