[v9.2.x] Expressions: Fixes the issue showing expressions editor (#62626)

* 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

(cherry picked from commit 91221bc436)

* unit text fix
This commit is contained in:
ismail simsek
2023-01-31 20:59:01 +01:00
committed by GitHub
parent 71f7f534ff
commit e2e9479e53
49 changed files with 207 additions and 191 deletions
+12 -11
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"
@@ -99,7 +100,7 @@ func TestAlertRulePermissions(t *testing.T) {
"from":18000,
"to":10800
},
"datasourceUid":"-100",
"datasourceUid":"__expr__",
"model":{
"expression":"2 + 3 \u003E 1",
"intervalMs":1000,
@@ -149,7 +150,7 @@ func TestAlertRulePermissions(t *testing.T) {
"from":18000,
"to":10800
},
"datasourceUid":"-100",
"datasourceUid":"__expr__",
"model":{
"expression":"2 + 3 \u003E 1",
"intervalMs":1000,
@@ -222,7 +223,7 @@ func TestAlertRulePermissions(t *testing.T) {
"from":18000,
"to":10800
},
"datasourceUid":"-100",
"datasourceUid":"__expr__",
"model":{
"expression":"2 + 3 \u003E 1",
"intervalMs":1000,
@@ -295,7 +296,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"
@@ -431,7 +432,7 @@ func TestRulerRulesFilterByDashboard(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"
@@ -451,7 +452,7 @@ func TestRulerRulesFilterByDashboard(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"
@@ -493,7 +494,7 @@ func TestRulerRulesFilterByDashboard(t *testing.T) {
"from": 18000,
"to": 10800
},
"datasourceUid": "-100",
"datasourceUid": "__expr__",
"model": {
"expression": "2 + 3 \u003e 1",
"intervalMs": 1000,
@@ -526,7 +527,7 @@ func TestRulerRulesFilterByDashboard(t *testing.T) {
"from": 18000,
"to": 10800
},
"datasourceUid": "-100",
"datasourceUid": "__expr__",
"model": {
"expression": "2 + 3 \u003e 1",
"intervalMs": 1000,
@@ -571,7 +572,7 @@ func TestRulerRulesFilterByDashboard(t *testing.T) {
"from": 18000,
"to": 10800
},
"datasourceUid": "-100",
"datasourceUid": "__expr__",
"model": {
"expression": "2 + 3 \u003e 1",
"intervalMs": 1000,
@@ -879,7 +880,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"
@@ -906,7 +907,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"