Expressions: Fixes the issue showing expressions editor (#62510)

* Use suggested value for uid

* update the snapshot

* use __expr__

* replace all -100 with __expr__

* update snapshot

* more changes

* revert redundant change

* Use expr.DatasourceUID where it's possible

* generate files
This commit is contained in:
ismail simsek
2023-01-31 18:50:10 +01:00
committed by GitHub
parent fdb1a47ca2
commit 91221bc436
54 changed files with 259 additions and 242 deletions

View File

@@ -9,6 +9,7 @@ import (
"testing"
"time"
"github.com/grafana/grafana/pkg/expr"
"github.com/prometheus/common/model"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
@@ -101,7 +102,7 @@ func TestIntegrationAlertRulePermissions(t *testing.T) {
"from":18000,
"to":10800
},
"datasourceUid":"-100",
"datasourceUid":"__expr__",
"model":{
"expression":"2 + 3 \u003E 1",
"intervalMs":1000,
@@ -151,7 +152,7 @@ func TestIntegrationAlertRulePermissions(t *testing.T) {
"from":18000,
"to":10800
},
"datasourceUid":"-100",
"datasourceUid":"__expr__",
"model":{
"expression":"2 + 3 \u003E 1",
"intervalMs":1000,
@@ -224,7 +225,7 @@ func TestIntegrationAlertRulePermissions(t *testing.T) {
"from":18000,
"to":10800
},
"datasourceUid":"-100",
"datasourceUid":"__expr__",
"model":{
"expression":"2 + 3 \u003E 1",
"intervalMs":1000,
@@ -297,7 +298,7 @@ func createRule(t *testing.T, client apiClient, folder string) {
From: ngmodels.Duration(time.Duration(5) * time.Hour),
To: ngmodels.Duration(time.Duration(3) * time.Hour),
},
DatasourceUID: "-100",
DatasourceUID: expr.DatasourceUID,
Model: json.RawMessage(`{
"type": "math",
"expression": "2 + 3 > 1"
@@ -437,7 +438,7 @@ func TestIntegrationRulerRulesFilterByDashboard(t *testing.T) {
From: ngmodels.Duration(time.Duration(5) * time.Hour),
To: ngmodels.Duration(time.Duration(3) * time.Hour),
},
DatasourceUID: "-100",
DatasourceUID: expr.DatasourceUID,
Model: json.RawMessage(`{
"type": "math",
"expression": "2 + 3 > 1"
@@ -457,7 +458,7 @@ func TestIntegrationRulerRulesFilterByDashboard(t *testing.T) {
From: ngmodels.Duration(time.Duration(5) * time.Hour),
To: ngmodels.Duration(time.Duration(3) * time.Hour),
},
DatasourceUID: "-100",
DatasourceUID: expr.DatasourceUID,
Model: json.RawMessage(`{
"type": "math",
"expression": "2 + 3 > 1"
@@ -499,7 +500,7 @@ func TestIntegrationRulerRulesFilterByDashboard(t *testing.T) {
"from": 18000,
"to": 10800
},
"datasourceUid": "-100",
"datasourceUid": "__expr__",
"model": {
"expression": "2 + 3 \u003e 1",
"intervalMs": 1000,
@@ -532,7 +533,7 @@ func TestIntegrationRulerRulesFilterByDashboard(t *testing.T) {
"from": 18000,
"to": 10800
},
"datasourceUid": "-100",
"datasourceUid": "__expr__",
"model": {
"expression": "2 + 3 \u003e 1",
"intervalMs": 1000,
@@ -577,7 +578,7 @@ func TestIntegrationRulerRulesFilterByDashboard(t *testing.T) {
"from": 18000,
"to": 10800
},
"datasourceUid": "-100",
"datasourceUid": "__expr__",
"model": {
"expression": "2 + 3 \u003e 1",
"intervalMs": 1000,
@@ -889,7 +890,7 @@ func newTestingRuleConfig(t *testing.T) apimodels.PostableRuleGroupConfig {
From: ngmodels.Duration(time.Duration(5) * time.Hour),
To: ngmodels.Duration(time.Duration(3) * time.Hour),
},
DatasourceUID: "-100",
DatasourceUID: expr.DatasourceUID,
Model: json.RawMessage(`{
"type": "math",
"expression": "2 + 3 > 1"
@@ -916,7 +917,7 @@ func newTestingRuleConfig(t *testing.T) apimodels.PostableRuleGroupConfig {
From: ngmodels.Duration(time.Duration(5) * time.Hour),
To: ngmodels.Duration(time.Duration(3) * time.Hour),
},
DatasourceUID: "-100",
DatasourceUID: expr.DatasourceUID,
Model: json.RawMessage(`{
"type": "math",
"expression": "2 + 3 > 1"