Skip to content

Commit

Permalink
fix monitor unit tests
Browse files Browse the repository at this point in the history
Signed-off-by: constanca <[email protected]>
  • Loading branch information
constanca-m authored and zmoog committed Mar 19, 2024
1 parent 22c42af commit e0e5e7e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions x-pack/metricbeat/module/azure/monitor/client_helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func TestMapMetric(t *testing.T) {
client := azure.NewMockClient()
t.Run("return error when no metric definitions were found", func(t *testing.T) {
m := &azure.MockService{}
m.On("GetMetricDefinitions", mock.Anything, mock.Anything).Return(armmonitor.MetricDefinitionCollection{}, fmt.Errorf("invalid resource ID"))
m.On("GetMetricDefinitionsWithRetry", mock.Anything, mock.Anything).Return(armmonitor.MetricDefinitionCollection{}, fmt.Errorf("invalid resource ID"))
client.AzureMonitorService = m
metric, err := mapMetrics(client, []*armresources.GenericResourceExpanded{resource}, resourceConfig)
assert.Error(t, err)
Expand All @@ -97,7 +97,7 @@ func TestMapMetric(t *testing.T) {
})
t.Run("return all metrics when all metric names and aggregations were configured", func(t *testing.T) {
m := &azure.MockService{}
m.On("GetMetricDefinitions", mock.Anything, mock.Anything).Return(metricDefinitions, nil)
m.On("GetMetricDefinitionsWithRetry", mock.Anything, mock.Anything).Return(metricDefinitions, nil)
client.AzureMonitorService = m
metricConfig.Name = []string{"*"}
resourceConfig.Metrics = []azure.MetricConfig{metricConfig}
Expand All @@ -112,7 +112,7 @@ func TestMapMetric(t *testing.T) {
})
t.Run("return all metrics when specific metric names and aggregations were configured", func(t *testing.T) {
m := &azure.MockService{}
m.On("GetMetricDefinitions", mock.Anything, mock.Anything).Return(metricDefinitions, nil)
m.On("GetMetricDefinitionsWithRetry", mock.Anything, mock.Anything).Return(metricDefinitions, nil)
client.AzureMonitorService = m
metricConfig.Name = []string{"TotalRequests", "Capacity"}
metricConfig.Aggregations = []string{"Average"}
Expand Down

0 comments on commit e0e5e7e

Please sign in to comment.