FeatureFlags: Cleanup usage of cfg.IsFeatureToggleEnabled (#78014)

This commit is contained in:
Ryan McKinley
2023-11-13 07:55:15 -08:00
committed by GitHub
parent 2b146b97b4
commit 3509a5abb9
37 changed files with 147 additions and 211 deletions

View File

@@ -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
}