mirror of
https://github.com/weaveworks/scope.git
synced 2026-03-02 17:50:39 +00:00
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:
@@ -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]
|
||||
|
||||
Reference in New Issue
Block a user