Skip to content

Commit

Permalink
test: happy path unit test added
Browse files Browse the repository at this point in the history
Signed-off-by: Sudipto Baral <[email protected]>
  • Loading branch information
sudiptob2 committed Mar 4, 2023
1 parent 9083f30 commit 4d16296
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func TestEvaluateQuery_HappyPath(t *testing.T) {
require.Nil(t, err)
}))
defer svr.Close()
secretName, secretKey, secretValue := "datadogToken", "apiKey", "value"
secretName, secretKey, secretValue := "datadogToken", "apiKey", "fake-api-key"
apiToken := &corev1.Secret{
ObjectMeta: metav1.ObjectMeta{
Name: secretName,
Expand All @@ -41,9 +41,9 @@ func TestEvaluateQuery_HappyPath(t *testing.T) {
Log: ctrl.Log.WithName("testytest"),
K8sClient: fakeClient,
}
obj := metricsapi.KeptnMetric{
metric := metricsapi.KeptnMetric{
Spec: metricsapi.KeptnMetricSpec{
Query: "system.cpu.idle{*}",
Query: "system.cpu.idle{}",
},
}
p := metricsapi.KeptnMetricsProvider{
Expand All @@ -54,12 +54,12 @@ func TestEvaluateQuery_HappyPath(t *testing.T) {
},
Key: secretKey,
},
TargetServer: "datadoghq.com", // TODO: replace with mock server
TargetServer: svr.URL,
},
}

r, raw, e := kdd.EvaluateQuery(context.TODO(), obj, p)
r, raw, e := kdd.EvaluateQuery(context.TODO(), metric, p)
require.Nil(t, e)
require.Equal(t, []byte(r), raw)
require.Equal(t, fmt.Sprintf("%f", 50.0), r)
require.Equal(t, []byte(ddPayload), raw)
require.Equal(t, fmt.Sprintf("%.3f", 84.782), r)
}

0 comments on commit 4d16296

Please sign in to comment.