Replace remaining calls to testing.Short where possible. (#110765)

* Replace remaining calls to testing.Short where possible.
* Update style guide.
* Revert change in TestAlertmanager_ExtraDedupStage, as it doesn't work.
* Make TestAlertRulePostExport into integration test.
This commit is contained in:
Peter Štibraný
2025-09-09 08:16:12 +00:00
committed by GitHub
parent ffcc0e8de0
commit c32650e9d8
16 changed files with 76 additions and 88 deletions
@@ -8,6 +8,7 @@ import (
)
func TestAlertmanager_ExtraDedupStage(t *testing.T) {
// TODO: rename test and call testutil.SkipIntegrationTestInShortMode(t)
if testing.Short() {
t.Skip("skipping integration test")
}
+1 -1
View File
@@ -711,7 +711,7 @@ func TestIntegrationAlertRuleNestedPermissions(t *testing.T) {
})
}
func TestAlertRulePostExport(t *testing.T) {
func TestIntegrationAlertRulePostExport(t *testing.T) {
testinfra.SQLiteIntegrationTest(t)
// Setup Grafana and its Database
+6 -4
View File
@@ -8,6 +8,7 @@ import (
"github.com/grafana/grafana-openapi-client-go/client/folders"
"github.com/grafana/grafana-openapi-client-go/models"
"github.com/grafana/grafana/pkg/services/accesscontrol/resourcepermissions"
"github.com/grafana/grafana/pkg/services/featuremgmt"
"github.com/grafana/grafana/pkg/services/folder"
@@ -17,6 +18,8 @@ import (
"github.com/grafana/grafana/pkg/tests/testinfra"
"github.com/grafana/grafana/pkg/tests/testsuite"
"github.com/grafana/grafana/pkg/util/retryer"
"github.com/grafana/grafana/pkg/util/testutil"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
@@ -25,10 +28,9 @@ func TestMain(m *testing.M) {
testsuite.Run(m)
}
func TestGetFolders(t *testing.T) {
if testing.Short() {
t.Skip("skipping integration test")
}
func TestIntegrationGetFolders(t *testing.T) {
testutil.SkipIntegrationTestInShortMode(t)
// Setup Grafana and its Database
dir, p := testinfra.CreateGrafDir(t, testinfra.GrafanaOpts{
DisableLegacyAlerting: true,
@@ -15,6 +15,8 @@ import (
"github.com/grafana/grafana/pkg/setting"
"github.com/grafana/grafana/pkg/tests/apis"
"github.com/grafana/grafana/pkg/tests/testinfra"
"github.com/grafana/grafana/pkg/util/testutil"
"github.com/stretchr/testify/require"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/runtime/schema"
@@ -27,9 +29,7 @@ var gvrServiceAccounts = schema.GroupVersionResource{
}
func TestIntegrationServiceAccounts(t *testing.T) {
if testing.Short() {
t.Skip("skipping integration test")
}
testutil.SkipIntegrationTestInShortMode(t)
// TODO: Figure out why rest.Mode4 is failing
modes := []rest.DualWriterMode{rest.Mode0, rest.Mode1, rest.Mode2, rest.Mode3}
+4 -4
View File
@@ -4,12 +4,12 @@ import (
"testing"
"github.com/stretchr/testify/require"
"github.com/grafana/grafana/pkg/util/testutil"
)
func TestPluginsIntegrationDiscovery(t *testing.T) {
if testing.Short() {
t.Skip("skipping integration test")
}
func TestIntegrationPluginsIntegrationDiscovery(t *testing.T) {
testutil.SkipIntegrationTestInShortMode(t)
t.Run("discovery", func(t *testing.T) {
helper := setupHelper(t)
@@ -16,10 +16,8 @@ import (
"github.com/grafana/grafana/pkg/util/testutil"
)
func TestProvisioning_ExportUnifiedToRepository(t *testing.T) {
if testing.Short() {
t.Skip("skipping integration test")
}
func TestIntegrationProvisioning_ExportUnifiedToRepository(t *testing.T) {
testutil.SkipIntegrationTestInShortMode(t)
helper := runGrafana(t)
ctx := context.Background()
+7 -4
View File
@@ -12,14 +12,16 @@ import (
"testing"
"time"
"github.com/grafana/grafana/pkg/configprovider"
"github.com/grafana/grafana/pkg/services/featuremgmt"
"github.com/grafana/grafana/pkg/services/sqlstore/sqlutil"
"github.com/prometheus/client_golang/prometheus"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"gopkg.in/ini.v1"
"github.com/grafana/grafana/pkg/configprovider"
"github.com/grafana/grafana/pkg/services/featuremgmt"
"github.com/grafana/grafana/pkg/services/sqlstore/sqlutil"
"github.com/grafana/grafana/pkg/util/testutil"
"github.com/grafana/dskit/kv"
"github.com/grafana/grafana/pkg/api"
@@ -570,8 +572,9 @@ func CreateGrafDir(t *testing.T, opts GrafanaOpts) (string, string) {
func SQLiteIntegrationTest(t *testing.T) {
t.Helper()
testutil.SkipIntegrationTestInShortMode(t)
if testing.Short() || !db.IsTestDbSQLite() {
if !db.IsTestDbSQLite() {
t.Skip("skipping integration test")
}
}