Skip to content

Commit

Permalink
DEV-45405 - Fix grafana unit tests
Browse files Browse the repository at this point in the history
api_notification_channel_test.go
error_handling_test.go
api_plugins_test.go - updated the expectedListResp.json
  • Loading branch information
yasmin-tr committed Jun 17, 2024
1 parent 4fc0f05 commit a474edb
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
4 changes: 2 additions & 2 deletions pkg/tests/api/alerting/api_notification_channel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1298,7 +1298,7 @@ func (nc *mockNotificationChannel) matchesExpNotifications(t *testing.T, exp map
r1 = regexp.MustCompile(`.*"source"\s*:\s*"([^"]+)"`)
case "googlechat_recv/googlechat_test":
// "Grafana v | 25 May 21 17:44 IST"
r1 = regexp.MustCompile(`.*"text"\s*:\s*"(Grafana v[^"]+)"`)
r1 = regexp.MustCompile(`.*"text"\s*:\s*"([^"]+)"`) // LOGZ.IO GRAFANA CHANGE :: DEV-43549 Fix Google chat notification messages
case "victorops_recv/victorops_test":
// It has a time component "timestamp".
r1 = regexp.MustCompile(`.*"timestamp"\s*:\s*([0-9]+)`)
Expand Down Expand Up @@ -2755,7 +2755,7 @@ var expNonEmailNotifications = map[string][]string{
"buttons": [
{
"textButton": {
"text": "OPEN IN GRAFANA",
"text": "OPEN IN LOGZIO",
"onClick": {
"openLink": {
"url": "http://localhost:3000/alerting/list"
Expand Down
2 changes: 1 addition & 1 deletion pkg/tests/api/plugins/data/expectedListResp.json
Original file line number Diff line number Diff line change
Expand Up @@ -1175,7 +1175,7 @@
"hasUpdate": false,
"defaultNavUrl": "/plugins/news/",
"category": "",
"state": "beta",
"state": "deprecated",
"signature": "internal",
"signatureType": "",
"signatureOrg": "",
Expand Down
18 changes: 16 additions & 2 deletions pkg/tsdb/elasticsearch/error_handling_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,14 @@ func TestErrorAvgMissingField(t *testing.T) {
require.NoError(t, err)

// FIXME: we should return the received error message
require.Len(t, result.response.Responses, 0)
// LOGZ.IO GRAFANA CHANGE :: DEV-43744 - Add error msg
require.Len(t, result.response.Responses, 1)
dataResponse, ok := result.response.Responses["A"]

require.True(t, ok)
require.Len(t, dataResponse.Frames, 0)
require.ErrorContains(t, dataResponse.Error, "got bad response status from datasource. StatusCode: 400")
// LOGZ.IO GRAFANA CHANGE :: End
}

func TestErrorAvgMissingFieldNoDetailedErrors(t *testing.T) {
Expand Down Expand Up @@ -69,7 +76,14 @@ func TestErrorAvgMissingFieldNoDetailedErrors(t *testing.T) {
require.NoError(t, err)

// FIXME: we should return the received error message
require.Len(t, result.response.Responses, 0)
// LOGZ.IO GRAFANA CHANGE :: DEV-43744 - Add error msg
require.Len(t, result.response.Responses, 1)
dataResponse, ok := result.response.Responses["A"]

require.True(t, ok)
require.Len(t, dataResponse.Frames, 0)
require.ErrorContains(t, dataResponse.Error, "got bad response status from datasource. StatusCode: 400")
// LOGZ.IO GRAFANA CHANGE :: End
}

func TestErrorTooManyDateHistogramBuckets(t *testing.T) {
Expand Down

0 comments on commit a474edb

Please sign in to comment.