Alerting: Refactor integration tests (#99519)

---------

Signed-off-by: Yuri Tseretyan <yuriy.tseretyan@grafana.com>
(cherry picked from commit af663dadc7)
This commit is contained in:
Yuri Tseretyan
2025-01-24 14:49:05 -05:00
committed by Moustafa Baiou
parent 822e5fb1a1
commit 2728e5cf14
5 changed files with 2147 additions and 2149 deletions
@@ -4,8 +4,7 @@ import (
"context"
"encoding/json"
"net/http"
"os"
"path/filepath"
"path"
"testing"
"github.com/grafana/grafana-plugin-sdk-go/data"
@@ -23,7 +22,7 @@ import (
)
func TestBacktesting(t *testing.T) {
dir, path := testinfra.CreateGrafDir(t, testinfra.GrafanaOpts{
dir, grafanaPath := testinfra.CreateGrafDir(t, testinfra.GrafanaOpts{
DisableLegacyAlerting: true,
EnableUnifiedAlerting: true,
DisableAnonymous: true,
@@ -34,7 +33,7 @@ func TestBacktesting(t *testing.T) {
EnableLog: false,
})
grafanaListedAddr, env := testinfra.StartGrafanaEnv(t, dir, path)
grafanaListedAddr, env := testinfra.StartGrafanaEnv(t, dir, grafanaPath)
userId := createUser(t, env.SQLStore, env.Cfg, user.CreateUserCommand{
DefaultOrgRole: string(org.RoleAdmin),
@@ -44,7 +43,7 @@ func TestBacktesting(t *testing.T) {
apiCli := newAlertingApiClient(grafanaListedAddr, "admin", "admin")
input, err := os.ReadFile(filepath.Join("api_backtesting_data.json"))
input, err := testData.ReadFile(path.Join("test-data", "api_backtesting_data.json"))
require.NoError(t, err)
var testData map[string]apimodels.BacktestConfig
require.NoError(t, json.Unmarshal(input, &testData))