fix accidental report fixture modification

Report.Copy() shallow-copies the nodes in Report.Nodes. Hence
Node.Metrics is shared between the original and the copy. Hence bad
things happen when modifying it.

This bug has laid dormant because by luck other tests in detailed_test
involving metrics are executed first.
This commit is contained in:
Matthias Radestock
2017-12-23 22:21:24 +00:00
parent 9c01613db1
commit 651e42e54e

View File

@@ -49,8 +49,10 @@ func TestSummaries(t *testing.T) {
t1, t2 := mtime.Now().Add(-1*time.Minute), mtime.Now()
metric := report.MakeMetric([]report.Sample{{Timestamp: t1, Value: 1}, {Timestamp: t2, Value: 2}})
input := fixture.Report.Copy()
input.Process.Nodes[fixture.ClientProcess1NodeID].Metrics[process.CPUUsage] = metric
processNode := input.Process.Nodes[fixture.ClientProcess1NodeID]
processNode.Metrics = processNode.Metrics.Copy()
processNode.Metrics[process.CPUUsage] = metric
input.Process.Nodes[fixture.ClientProcess1NodeID] = processNode
have := detailed.Summaries(report.RenderContext{Report: input}, render.ProcessRenderer.Render(input).Nodes)
node, ok := have[fixture.ClientProcess1NodeID]