mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
FeatureFlags: Cleanup usage of cfg.IsFeatureToggleEnabled (#78014)
This commit is contained in:
@@ -23,7 +23,7 @@ type sqlStoreTest struct {
|
||||
dbUser string
|
||||
dbPwd string
|
||||
expConnStr string
|
||||
features []string
|
||||
features featuremgmt.FeatureToggles
|
||||
err error
|
||||
}
|
||||
|
||||
@@ -101,14 +101,14 @@ var sqlStoreTestCases = []sqlStoreTest{
|
||||
name: "MySQL with ANSI_QUOTES mode",
|
||||
dbType: "mysql",
|
||||
dbHost: "[::1]",
|
||||
features: []string{featuremgmt.FlagMysqlAnsiQuotes},
|
||||
features: featuremgmt.WithFeatures(featuremgmt.FlagMysqlAnsiQuotes),
|
||||
expConnStr: ":@tcp([::1])/test_db?collation=utf8mb4_unicode_ci&allowNativePasswords=true&clientFoundRows=true&sql_mode='ANSI_QUOTES'",
|
||||
},
|
||||
{
|
||||
name: "New DB library",
|
||||
dbType: "mysql",
|
||||
dbHost: "[::1]",
|
||||
features: []string{featuremgmt.FlagNewDBLibrary},
|
||||
features: featuremgmt.WithFeatures(featuremgmt.FlagNewDBLibrary),
|
||||
expConnStr: ":@tcp([::1])/test_db?collation=utf8mb4_unicode_ci&allowNativePasswords=true&clientFoundRows=true&sql_mode='ANSI_QUOTES'&parseTime=true",
|
||||
},
|
||||
}
|
||||
@@ -180,7 +180,11 @@ func TestIntegrationIsUniqueConstraintViolation(t *testing.T) {
|
||||
func makeSQLStoreTestConfig(t *testing.T, tc sqlStoreTest) *setting.Cfg {
|
||||
t.Helper()
|
||||
|
||||
cfg := setting.NewCfg()
|
||||
if tc.features == nil {
|
||||
tc.features = featuremgmt.WithFeatures()
|
||||
}
|
||||
// nolint:staticcheck
|
||||
cfg := setting.NewCfgWithFeatures(tc.features.IsEnabled)
|
||||
|
||||
sec, err := cfg.Raw.NewSection("database")
|
||||
require.NoError(t, err)
|
||||
@@ -197,14 +201,5 @@ func makeSQLStoreTestConfig(t *testing.T, tc sqlStoreTest) *setting.Cfg {
|
||||
_, err = sec.NewKey("password", tc.dbPwd)
|
||||
require.NoError(t, err)
|
||||
|
||||
cfg.IsFeatureToggleEnabled = func(key string) bool {
|
||||
for _, f := range tc.features {
|
||||
if f == key {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
return cfg
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user