fix(historian): validate non-positive drain/capacity/retention knobs (review) + log prefix
This commit is contained in:
+25
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user