From 4994c1165c0aa6ad862800f0c5a5a95789b0b82e Mon Sep 17 00:00:00 2001 From: alvarocabanas Date: Fri, 18 Aug 2023 09:53:12 +0200 Subject: [PATCH] Fix test errors --- pkg/metrics/process/sampler_darwin_test.go | 7 +++++-- pkg/metrics/process/sampler_linux_test.go | 3 ++- pkg/metrics/procs_windows.go | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/pkg/metrics/process/sampler_darwin_test.go b/pkg/metrics/process/sampler_darwin_test.go index 4b6ae6f78..ffe1d90ca 100644 --- a/pkg/metrics/process/sampler_darwin_test.go +++ b/pkg/metrics/process/sampler_darwin_test.go @@ -4,12 +4,15 @@ package process import ( "errors" + "testing" + + "github.com/newrelic/infrastructure-agent/pkg/metrics" + "github.com/newrelic/infrastructure-agent/internal/agent/mocks" "github.com/newrelic/infrastructure-agent/pkg/config" "github.com/newrelic/infrastructure-agent/pkg/metrics/types" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" - "testing" ) func TestProcessSampler_Sample(t *testing.T) { @@ -110,7 +113,7 @@ func TestProcessSampler_Sample_DockerDecorator(t *testing.T) { harvester := &HarvesterMock{} sampler := NewProcessSampler(ctx).(*processSampler) sampler.harvest = harvester - sampler.containerSampler = &fakeContainerSampler{} + sampler.containerSamplers = []metrics.ContainerSampler{&fakeContainerSampler{}} samples := []*types.ProcessSample{ { diff --git a/pkg/metrics/process/sampler_linux_test.go b/pkg/metrics/process/sampler_linux_test.go index 5f3e823db..f2caa4047 100644 --- a/pkg/metrics/process/sampler_linux_test.go +++ b/pkg/metrics/process/sampler_linux_test.go @@ -18,6 +18,7 @@ import ( "github.com/newrelic/infrastructure-agent/pkg/config" "github.com/newrelic/infrastructure-agent/pkg/entity" "github.com/newrelic/infrastructure-agent/pkg/entity/host" + "github.com/newrelic/infrastructure-agent/pkg/metrics" "github.com/newrelic/infrastructure-agent/pkg/metrics/types" "github.com/newrelic/infrastructure-agent/pkg/plugins/ids" "github.com/newrelic/infrastructure-agent/pkg/sample" @@ -41,7 +42,7 @@ func TestProcessSampler_DockerDecorator(t *testing.T) { ProcessDisplayName: "Bye", }, }} - ps.containerSampler = &fakeContainerSampler{} + ps.containerSamplers = []metrics.ContainerSampler{&fakeContainerSampler{}} // When asking for the process samples samples, err := ps.Sample() diff --git a/pkg/metrics/procs_windows.go b/pkg/metrics/procs_windows.go index dbcc4315a..10ff1d0ac 100644 --- a/pkg/metrics/procs_windows.go +++ b/pkg/metrics/procs_windows.go @@ -662,7 +662,7 @@ func (self *ProcsMonitor) Sample() (results sample.EventBatch, err error) { } var containerDecorators []ProcessDecorator - for _, containerSampler := range ps.containerSamplers { + for _, containerSampler := range self.containerSamplers { if containerSampler.Enabled() { decorator, err := containerSampler.NewDecorator() if err != nil {