fix(historian): validate non-positive drain/capacity/retention knobs (review) + log prefix

This commit is contained in:
Joseph Doherty
2026-06-11 13:09:13 -04:00
parent f215982b93
commit 5ea6e9d7d9
3 changed files with 34 additions and 2 deletions
@@ -137,4 +137,29 @@ public sealed class AlarmHistorianRegistrationTests
{
new AlarmHistorianOptions { Enabled = false, SharedSecret = "" }.Validate().ShouldBeEmpty();
}
[Fact]
public void Validate_warns_on_non_positive_drain_interval()
{
var opts = new AlarmHistorianOptions { Enabled = true, SharedSecret = "s", DatabasePath = "/abs/h.db", DrainIntervalSeconds = 0 };
opts.Validate().ShouldContain(w => w.Contains("DrainIntervalSeconds"));
}
[Fact]
public void Validate_warns_on_non_positive_capacity()
{
var opts = new AlarmHistorianOptions { Enabled = true, SharedSecret = "s", DatabasePath = "/abs/h.db", Capacity = 0 };
opts.Validate().ShouldContain(w => w.Contains("Capacity"));
}
[Fact]
public void Validate_accumulates_multiple_warnings()
{
// relative path + empty secret ⇒ both warnings, not short-circuited on the first.
var opts = new AlarmHistorianOptions { Enabled = true, SharedSecret = "", DatabasePath = "alarm-historian.db" };
var warnings = opts.Validate();
warnings.ShouldContain(w => w.Contains("SharedSecret"));
warnings.ShouldContain(w => w.Contains("DatabasePath"));
warnings.Count.ShouldBeGreaterThanOrEqualTo(2);
}
}