fix(deploy): address M2.2 review nits — backup endpoint in diff summary + null-oldConfig test (#10)

- FormatConnection now includes BackupConfigurationJson so a backup-only change
  no longer renders identical Before/After cells (covers all 4 ConnectionsEqual fields)
- add ComputeConnectionsDiff(null, newConfig) first-deploy unit test
This commit is contained in:
Joseph Doherty
2026-06-15 13:41:39 -04:00
parent e9a84ba220
commit 198770f578
2 changed files with 40 additions and 3 deletions
@@ -286,6 +286,36 @@ public class DiffServiceTests
Assert.Equal("OpcUa", diff[0].NewValue!.Protocol);
}
[Fact]
public void ComputeConnectionsDiff_NullOldConfig_AllReportedAsAdded()
{
// First deploy: there is no prior flattened config at all (null), so
// every connection in the new config is Added. Exercises the public
// method's null-oldConfig tolerance explicitly (the ComputeDiff path
// covers it end-to-end, but the isolated API contract is asserted here).
var newConfig = new FlattenedConfiguration
{
InstanceUniqueName = "Instance1",
Connections = new Dictionary<string, ConnectionConfig>
{
["plc1"] = new ConnectionConfig
{
Protocol = "OpcUa",
ConfigurationJson = "{\"endpoint\":\"opc.tcp://host\"}",
FailoverRetryCount = 3,
}
}
};
var diff = _sut.ComputeConnectionsDiff(null, newConfig);
Assert.Single(diff);
Assert.Equal("plc1", diff[0].CanonicalName);
Assert.Equal(DiffChangeType.Added, diff[0].ChangeType);
Assert.Null(diff[0].OldValue);
Assert.Equal("OpcUa", diff[0].NewValue!.Protocol);
}
[Fact]
public void ComputeConnectionsDiff_BindingCleared_ReportedAsRemoved()
{