Move Counters into Latest

The only place Counters are used is in rendering, for the number of
nodes under a topology, so the overhead of holding a unique data
structure in every Node is unwarranted.
This commit is contained in:
Bryan Boreham
2019-10-20 10:16:36 +00:00
parent f73a220960
commit 4658568330
12 changed files with 68 additions and 345 deletions

View File

@@ -130,33 +130,31 @@ func TestMergeNodes(t *testing.T) {
}),
},
},
"Counters": {
a: report.Nodes{
"1": report.MakeNode("1").WithCounters(map[string]int{
"a": 13,
"b": 57,
"c": 89,
}),
},
b: report.Nodes{
"1": report.MakeNode("1").WithCounters(map[string]int{
"a": 78,
"b": 3,
"d": 47,
}),
},
want: report.Nodes{
"1": report.MakeNode("1").WithCounters(map[string]int{
"a": 91,
"b": 60,
"c": 89,
"d": 47,
}),
},
},
} {
if have := c.a.Merge(c.b); !reflect.DeepEqual(c.want, have) {
t.Errorf("%s: %s", name, test.Diff(c.want, have))
}
}
}
func TestCounters(t *testing.T) {
a := report.MakeNode("1").
WithCounter("a", 13).
WithCounter("b", 57).
WithCounter("c", 89)
b := a.
WithCounter("a", 78).
WithCounter("b", 3).
WithCounter("d", 47)
want := report.MakeNode("1").
WithCounter("a", 91).
WithCounter("b", 60).
WithCounter("c", 89).
WithCounter("d", 47)
if have := b; !reflect.DeepEqual(want, have) {
t.Errorf("Counters: %s", test.Diff(want, have))
}
}