diff --git a/metricproviders/datadog/datadogV2_test.go b/metricproviders/datadog/datadogV2_test.go index 4a897fea24..bb01dfce50 100644 --- a/metricproviders/datadog/datadogV2_test.go +++ b/metricproviders/datadog/datadogV2_test.go @@ -381,18 +381,20 @@ func TestValidateIncomingProps(t *testing.T) { expectedErrorMessage string }{ { - name: "query missing", + name: "query and queries missing", metric: &v1alpha1.DatadogMetric{ - Query: "", - Queries: nil, + ApiVersion: "v1", + Query: "", + Queries: nil, }, expectedErrorMessage: "Must have either a query or queries", }, { name: "both query and queries", metric: &v1alpha1.DatadogMetric{ - Query: "foo", - Queries: map[string]string{"a": "how much wood could a wood chuck chuck"}, + ApiVersion: "v1", + Query: "foo", + Queries: map[string]string{"a": "how much wood could a wood chuck chuck"}, }, expectedErrorMessage: "Cannot have both a query and queries", }, @@ -404,10 +406,19 @@ func TestValidateIncomingProps(t *testing.T) { }, expectedErrorMessage: "Query is empty. API Version v1 only supports using the query parameter in your Analysis Template.", }, + { + name: "formula/queries with wrong apiVersion", + metric: &v1alpha1.DatadogMetric{ + ApiVersion: "v1", + Queries: map[string]string{"a": "how much wood could a wood chuck chuck"}, + Formula: "a + b", + }, + expectedErrorMessage: "Query is empty. API Version v1 only supports using the query parameter in your Analysis Template.", + }, { name: "formula without queries", metric: &v1alpha1.DatadogMetric{ - ApiVersion: "v2", + ApiVersion: "v1", Formula: "foo / bar", Query: "foo", }, @@ -424,9 +435,10 @@ func TestValidateIncomingProps(t *testing.T) { { name: "valid queries with v2", metric: &v1alpha1.DatadogMetric{ - Query: "", - Queries: map[string]string{"a": "how much wood could a wood chuck chuck"}, - Formula: "a + b", + ApiVersion: "v2", + Query: "", + Queries: map[string]string{"a": "how much wood could a wood chuck chuck"}, + Formula: "a + b", }, expectedErrorMessage: "", },