Skip to content

Commit

Permalink
Fix tests to better reflect reality. Cover foruma + apiversion 1 case…
Browse files Browse the repository at this point in the history
… eg: we know ApiVersion is always provided since its a default
  • Loading branch information
meeech committed Sep 8, 2023
1 parent 398fd7f commit 56d2a66
Showing 1 changed file with 21 additions and 9 deletions.
30 changes: 21 additions & 9 deletions metricproviders/datadog/datadogV2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
Expand All @@ -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",
},
Expand All @@ -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: "",
},
Expand Down

0 comments on commit 56d2a66

Please sign in to comment.