Skip to content

Commit

Permalink
Updates tests
Browse files Browse the repository at this point in the history
  • Loading branch information
orlando-valdez-ck committed Jul 10, 2024
1 parent 828fcd1 commit a164452
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions metricproviders/newrelic/newrelic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,13 @@ func TestRunSuccessfully(t *testing.T) {
FailureCondition: "result.count != 10",
Provider: v1alpha1.MetricProvider{
NewRelic: &v1alpha1.NewRelicMetric{
Query: "test",
Query: "resolved-query",
},
},
}
metricsMetadata := p.GetMetadata(metric)
assert.Nil(t, metricsMetadata)
assert.NotNil(t, metricsMetadata)
assert.Equal(t, "resolved-query", metricsMetadata[resolvedNewRelicQuery])

measurement := p.Run(newAnalysisRun(), metric)
assert.NotNil(t, measurement.StartedAt)
Expand All @@ -60,7 +61,8 @@ func TestRunWithTimeseries(t *testing.T) {
response: []nrdb.NRDBResult{
map[string]any{"count": 10},
map[string]any{"count": 20},
map[string]any{"count": 30}},
map[string]any{"count": 30},
},
}
p := NewNewRelicProvider(mock, *e)
metric := v1alpha1.Metric{
Expand All @@ -69,12 +71,13 @@ func TestRunWithTimeseries(t *testing.T) {
FailureCondition: "result[2].count < 20",
Provider: v1alpha1.MetricProvider{
NewRelic: &v1alpha1.NewRelicMetric{
Query: "test",
Query: "resolved-query",
},
},
}
metricsMetadata := p.GetMetadata(metric)
assert.Nil(t, metricsMetadata)
assert.NotNil(t, metricsMetadata)
assert.Equal(t, "resolved-query", metricsMetadata[resolvedNewRelicQuery])

measurement := p.Run(newAnalysisRun(), metric)
assert.NotNil(t, measurement.StartedAt)
Expand All @@ -95,12 +98,13 @@ func TestRunWithFacet(t *testing.T) {
FailureCondition: "result.count != 10 or result['average.duration'] >= 15.0",
Provider: v1alpha1.MetricProvider{
NewRelic: &v1alpha1.NewRelicMetric{
Query: "test",
Query: "resolved-query",
},
},
}
metricsMetadata := p.GetMetadata(metric)
assert.Nil(t, metricsMetadata)
assert.NotNil(t, metricsMetadata)
assert.Equal(t, "resolved-query", metricsMetadata[resolvedNewRelicQuery])

measurement := p.Run(newAnalysisRun(), metric)
assert.NotNil(t, measurement.StartedAt)
Expand All @@ -121,12 +125,13 @@ func TestRunWithMultipleSelectTerms(t *testing.T) {
FailureCondition: "result.count != 10",
Provider: v1alpha1.MetricProvider{
NewRelic: &v1alpha1.NewRelicMetric{
Query: "test",
Query: "resolved-query",
},
},
}
metricsMetadata := p.GetMetadata(metric)
assert.Nil(t, metricsMetadata)
assert.NotNil(t, metricsMetadata)
assert.Equal(t, "resolved-query", metricsMetadata[resolvedNewRelicQuery])

measurement := p.Run(newAnalysisRun(), metric)
assert.NotNil(t, measurement.StartedAt)
Expand Down

0 comments on commit a164452

Please sign in to comment.