Chore: Disable scopelint for tests (#25923)

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
pull/25931/head
Arve Knudsen 5 years ago committed by GitHub
parent 02cd1a441f
commit 3651a8e976
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      pkg/api/dashboard_test.go
  2. 2
      pkg/api/folder_test.go
  3. 2
      pkg/api/login_test.go
  4. 1
      pkg/api/pluginproxy/access_token_provider_test.go
  5. 1
      pkg/api/pluginproxy/ds_proxy_test.go
  6. 6
      pkg/cmd/grafana-cli/commands/upgrade_all_command_test.go
  7. 2
      pkg/cmd/grafana-server/diagnostics_test.go
  8. 1
      pkg/components/gtime/gtime_test.go
  9. 1
      pkg/login/social/azuread_oauth_test.go
  10. 3
      pkg/login/social/generic_oauth_test.go
  11. 1
      pkg/plugins/backendplugin/grpcplugin/log_wrapper_test.go
  12. 1
      pkg/plugins/plugins_test.go
  13. 1
      pkg/services/alerting/alerting_usage_test.go
  14. 6
      pkg/services/guardian/guardian_test.go
  15. 1
      pkg/services/sqlstore/migrations/migrations_test.go
  16. 1
      pkg/services/sqlstore/sqlstore_test.go
  17. 1
      pkg/tsdb/azuremonitor/applicationinsights-datasource_test.go
  18. 1
      pkg/tsdb/azuremonitor/applicationinsights-metrics_test.go
  19. 2
      pkg/tsdb/azuremonitor/azure-log-analytics-datasource_test.go
  20. 1
      pkg/tsdb/azuremonitor/azure-log-analytics-table-frame_test.go
  21. 3
      pkg/tsdb/azuremonitor/azuremonitor-datasource_test.go
  22. 1
      pkg/tsdb/azuremonitor/macros_test.go
  23. 1
      pkg/tsdb/frame_util_test.go
  24. 1
      pkg/tsdb/influxdb/flux/macros_test.go
  25. 4
      scripts/go/configs/.golangci.toml
  26. 4
      scripts/go/configs/ci/.golangci.toml

@ -42,7 +42,6 @@ func TestGetHomeDashboard(t *testing.T) {
} }
for _, tc := range tests { for _, tc := range tests {
tc := tc
t.Run(tc.name, func(t *testing.T) { t.Run(tc.name, func(t *testing.T) {
dash := dtos.DashboardFullWithMeta{} dash := dtos.DashboardFullWithMeta{}
dash.Meta.IsHome = true dash.Meta.IsHome = true
@ -802,7 +801,6 @@ func TestDashboardApiEndpoint(t *testing.T) {
} }
for _, tc := range testCases { for _, tc := range testCases {
tc := tc
mock := &dashboards.FakeDashboardService{ mock := &dashboards.FakeDashboardService{
SaveDashboardError: tc.SaveError, SaveDashboardError: tc.SaveError,
} }

@ -62,7 +62,6 @@ func TestFoldersApiEndpoint(t *testing.T) {
} }
for _, tc := range testCases { for _, tc := range testCases {
tc := tc
mock := &fakeFolderService{ mock := &fakeFolderService{
CreateFolderError: tc.Error, CreateFolderError: tc.Error,
} }
@ -120,7 +119,6 @@ func TestFoldersApiEndpoint(t *testing.T) {
} }
for _, tc := range testCases { for _, tc := range testCases {
tc := tc
mock := &fakeFolderService{ mock := &fakeFolderService{
UpdateFolderError: tc.Error, UpdateFolderError: tc.Error,
} }

@ -252,7 +252,6 @@ func TestLoginViewRedirect(t *testing.T) {
} }
for _, c := range redirectCases { for _, c := range redirectCases {
c := c
hs.Cfg.AppUrl = c.appURL hs.Cfg.AppUrl = c.appURL
hs.Cfg.AppSubUrl = c.appSubURL hs.Cfg.AppSubUrl = c.appSubURL
t.Run(c.desc, func(t *testing.T) { t.Run(c.desc, func(t *testing.T) {
@ -421,7 +420,6 @@ func TestLoginPostRedirect(t *testing.T) {
} }
for _, c := range redirectCases { for _, c := range redirectCases {
c := c
hs.Cfg.AppUrl = c.appURL hs.Cfg.AppUrl = c.appURL
hs.Cfg.AppSubUrl = c.appSubURL hs.Cfg.AppSubUrl = c.appSubURL
t.Run(c.desc, func(t *testing.T) { t.Run(c.desc, func(t *testing.T) {

@ -189,7 +189,6 @@ func TestAccessToken(t *testing.T) {
}, },
} }
for _, testCase := range testCases { for _, testCase := range testCases {
testCase := testCase
Convey(testCase.desc, func() { Convey(testCase.desc, func() {
clearTokenCache() clearTokenCache()
// reset the httphandler counter // reset the httphandler counter

@ -617,7 +617,6 @@ func TestNewDataSourceProxy_MSSQL(t *testing.T) {
}, },
} }
for _, tc := range tcs { for _, tc := range tcs {
tc := tc
t.Run(tc.description, func(t *testing.T) { t.Run(tc.description, func(t *testing.T) {
cfg := setting.Cfg{} cfg := setting.Cfg{}
plugin := plugins.DataSourcePlugin{} plugin := plugins.DataSourcePlugin{}

@ -21,10 +21,9 @@ func TestVersionComparison(t *testing.T) {
} }
for k, v := range upgradeablePlugins { for k, v := range upgradeablePlugins {
key := k
val := v val := v
t.Run(fmt.Sprintf("for %s should be true", k), func(t *testing.T) { t.Run(fmt.Sprintf("for %s should be true", k), func(t *testing.T) {
assert.True(t, shouldUpgrade(key, &val)) assert.True(t, shouldUpgrade(k, &val))
}) })
} }
}) })
@ -41,10 +40,9 @@ func TestVersionComparison(t *testing.T) {
} }
for k, v := range shouldNotUpgrade { for k, v := range shouldNotUpgrade {
key := k
val := v val := v
t.Run(fmt.Sprintf("for %s should be false", k), func(t *testing.T) { t.Run(fmt.Sprintf("for %s should be false", k), func(t *testing.T) {
assert.False(t, shouldUpgrade(key, &val)) assert.False(t, shouldUpgrade(k, &val))
}) })
} }
}) })

@ -23,7 +23,6 @@ func TestProfilingDiagnostics(t *testing.T) {
} }
for i, tc := range tcs { for i, tc := range tcs {
tc := tc
t.Run(fmt.Sprintf("testcase %d", i), func(t *testing.T) { t.Run(fmt.Sprintf("testcase %d", i), func(t *testing.T) {
os.Clearenv() os.Clearenv()
if tc.enabledEnv != "" { if tc.enabledEnv != "" {
@ -56,7 +55,6 @@ func TestTracingDiagnostics(t *testing.T) {
} }
for i, tc := range tcs { for i, tc := range tcs {
tc := tc
t.Run(fmt.Sprintf("testcase %d", i), func(t *testing.T) { t.Run(fmt.Sprintf("testcase %d", i), func(t *testing.T) {
os.Clearenv() os.Clearenv()
if tc.enabledEnv != "" { if tc.enabledEnv != "" {

@ -26,7 +26,6 @@ func TestParseInterval(t *testing.T) {
} }
for i, tc := range tcs { for i, tc := range tcs {
tc := tc
t.Run(fmt.Sprintf("testcase %d", i), func(t *testing.T) { t.Run(fmt.Sprintf("testcase %d", i), func(t *testing.T) {
res, err := ParseInterval(tc.interval) res, err := ParseInterval(tc.interval)
if tc.err == "" { if tc.err == "" {

@ -221,7 +221,6 @@ func TestSocialAzureAD_UserInfo(t *testing.T) {
}, },
} }
for _, tt := range tests { for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
s := &SocialAzureAD{ s := &SocialAzureAD{
SocialBase: tt.fields.SocialBase, SocialBase: tt.fields.SocialBase,

@ -89,7 +89,6 @@ func TestSearchJSONForEmail(t *testing.T) {
} }
for _, test := range tests { for _, test := range tests {
test := test
provider.emailAttributePath = test.EmailAttributePath provider.emailAttributePath = test.EmailAttributePath
t.Run(test.Name, func(t *testing.T) { t.Run(test.Name, func(t *testing.T) {
actualResult, err := provider.searchJSONForAttr(test.EmailAttributePath, test.UserInfoJSONResponse) actualResult, err := provider.searchJSONForAttr(test.EmailAttributePath, test.UserInfoJSONResponse)
@ -153,7 +152,6 @@ func TestSearchJSONForRole(t *testing.T) {
} }
for _, test := range tests { for _, test := range tests {
test := test
provider.roleAttributePath = test.RoleAttributePath provider.roleAttributePath = test.RoleAttributePath
t.Run(test.Name, func(t *testing.T) { t.Run(test.Name, func(t *testing.T) {
actualResult, err := provider.searchJSONForAttr(test.RoleAttributePath, test.UserInfoJSONResponse) actualResult, err := provider.searchJSONForAttr(test.RoleAttributePath, test.UserInfoJSONResponse)
@ -306,7 +304,6 @@ func TestUserInfoSearchesForEmailAndRole(t *testing.T) {
} }
for _, test := range tests { for _, test := range tests {
test := test
provider.roleAttributePath = test.RoleAttributePath provider.roleAttributePath = test.RoleAttributePath
t.Run(test.Name, func(t *testing.T) { t.Run(test.Name, func(t *testing.T) {
response, err := json.Marshal(test.APIURLResponse) response, err := json.Marshal(test.APIURLResponse)

@ -21,7 +21,6 @@ func TestLogWrapper(t *testing.T) {
} }
for i, tc := range tcs { for i, tc := range tcs {
tc := tc
t.Run(fmt.Sprintf("formatArgs testcase %d", i), func(t *testing.T) { t.Run(fmt.Sprintf("formatArgs testcase %d", i), func(t *testing.T) {
res := formatArgs(tc.args...) res := formatArgs(tc.args...)
assert.Exactly(t, tc.expectedResult, res) assert.Exactly(t, tc.expectedResult, res)

@ -177,7 +177,6 @@ func TestPluginManager_IsBackendOnlyPlugin(t *testing.T) {
{name: "renderer", isBackendOnly: true}, {name: "renderer", isBackendOnly: true},
{name: "app", isBackendOnly: false}, {name: "app", isBackendOnly: false},
} { } {
c := c
t.Run(fmt.Sprintf("Plugin %s", c.name), func(t *testing.T) { t.Run(fmt.Sprintf("Plugin %s", c.name), func(t *testing.T) {
result := pluginScanner.IsBackendOnlyPlugin(c.name) result := pluginScanner.IsBackendOnlyPlugin(c.name)

@ -107,7 +107,6 @@ func TestParsingAlertRuleSettings(t *testing.T) {
require.NoError(t, err, "Init should not return an error") require.NoError(t, err, "Init should not return an error")
for _, tc := range tcs { for _, tc := range tcs {
tc := tc
t.Run(tc.name, func(t *testing.T) { t.Run(tc.name, func(t *testing.T) {
content, err := ioutil.ReadFile(tc.file) content, err := ioutil.ReadFile(tc.file)
require.NoError(t, err, "expected to be able to read file") require.NoError(t, err, "expected to be able to read file")

@ -372,7 +372,6 @@ func (sc *scenarioContext) verifyUpdateDashboardPermissionsShouldBeAllowed(pt pe
} }
for _, p := range []models.PermissionType{models.PERMISSION_ADMIN, models.PERMISSION_EDIT, models.PERMISSION_VIEW} { for _, p := range []models.PermissionType{models.PERMISSION_ADMIN, models.PERMISSION_EDIT, models.PERMISSION_VIEW} {
p := p
tc := fmt.Sprintf("When updating dashboard permissions with %s permissions should be allowed", p.String()) tc := fmt.Sprintf("When updating dashboard permissions with %s permissions should be allowed", p.String())
Convey(tc, func() { Convey(tc, func() {
@ -421,7 +420,6 @@ func (sc *scenarioContext) verifyUpdateDashboardPermissionsShouldNotBeAllowed(pt
} }
for _, p := range []models.PermissionType{models.PERMISSION_ADMIN, models.PERMISSION_EDIT, models.PERMISSION_VIEW} { for _, p := range []models.PermissionType{models.PERMISSION_ADMIN, models.PERMISSION_EDIT, models.PERMISSION_VIEW} {
p := p
tc := fmt.Sprintf("When updating dashboard permissions with %s permissions should NOT be allowed", p.String()) tc := fmt.Sprintf("When updating dashboard permissions with %s permissions should NOT be allowed", p.String())
Convey(tc, func() { Convey(tc, func() {
@ -462,7 +460,6 @@ func (sc *scenarioContext) verifyUpdateChildDashboardPermissionsShouldBeAllowed(
} }
for _, p := range []models.PermissionType{models.PERMISSION_ADMIN, models.PERMISSION_EDIT, models.PERMISSION_VIEW} { for _, p := range []models.PermissionType{models.PERMISSION_ADMIN, models.PERMISSION_EDIT, models.PERMISSION_VIEW} {
p := p
tc := fmt.Sprintf("When updating child dashboard permissions with %s permissions should be allowed", p.String()) tc := fmt.Sprintf("When updating child dashboard permissions with %s permissions should be allowed", p.String())
Convey(tc, func() { Convey(tc, func() {
@ -526,7 +523,6 @@ func (sc *scenarioContext) verifyUpdateChildDashboardPermissionsShouldNotBeAllow
} }
for _, p := range []models.PermissionType{models.PERMISSION_ADMIN, models.PERMISSION_EDIT, models.PERMISSION_VIEW} { for _, p := range []models.PermissionType{models.PERMISSION_ADMIN, models.PERMISSION_EDIT, models.PERMISSION_VIEW} {
p := p
tc := fmt.Sprintf("When updating child dashboard permissions with %s permissions should NOT be allowed", p.String()) tc := fmt.Sprintf("When updating child dashboard permissions with %s permissions should NOT be allowed", p.String())
Convey(tc, func() { Convey(tc, func() {
@ -590,7 +586,6 @@ func (sc *scenarioContext) verifyUpdateChildDashboardPermissionsWithOverrideShou
} }
for _, p := range []models.PermissionType{models.PERMISSION_ADMIN, models.PERMISSION_EDIT, models.PERMISSION_VIEW} { for _, p := range []models.PermissionType{models.PERMISSION_ADMIN, models.PERMISSION_EDIT, models.PERMISSION_VIEW} {
p := p
// permission to update is higher than parent folder permission // permission to update is higher than parent folder permission
if p > parentFolderPermission { if p > parentFolderPermission {
continue continue
@ -636,7 +631,6 @@ func (sc *scenarioContext) verifyUpdateChildDashboardPermissionsWithOverrideShou
} }
for _, p := range []models.PermissionType{models.PERMISSION_ADMIN, models.PERMISSION_EDIT, models.PERMISSION_VIEW} { for _, p := range []models.PermissionType{models.PERMISSION_ADMIN, models.PERMISSION_EDIT, models.PERMISSION_VIEW} {
p := p
// permission to update is lower than or equal to parent folder permission // permission to update is lower than or equal to parent folder permission
if p <= parentFolderPermission { if p <= parentFolderPermission {
continue continue

@ -16,7 +16,6 @@ func TestMigrations(t *testing.T) {
} }
for _, testDB := range testDBs { for _, testDB := range testDBs {
testDB := testDB
sql := `select count(*) as count from migration_log` sql := `select count(*) as count from migration_log`
r := struct { r := struct {
Count int64 Count int64

@ -71,7 +71,6 @@ func TestSqlConnectionString(t *testing.T) {
t.Helper() t.Helper()
for _, testCase := range sqlStoreTestCases { for _, testCase := range sqlStoreTestCases {
testCase := testCase
Convey(testCase.name, func() { Convey(testCase.name, func() {
sqlstore := &SqlStore{} sqlstore := &SqlStore{}
sqlstore.Cfg = makeSqlStoreTestConfig(testCase.dbType, testCase.dbHost) sqlstore.Cfg = makeSqlStoreTestConfig(testCase.dbType, testCase.dbHost)

@ -195,7 +195,6 @@ func TestAppInsightsPluginRoutes(t *testing.T) {
} }
for _, tt := range tests { for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
route, routeName, err := datasource.getPluginRoute(plugin, tt.cloudName) route, routeName, err := datasource.getPluginRoute(plugin, tt.cloudName)
tt.Err(t, err) tt.Err(t, err)

@ -104,7 +104,6 @@ func TestInsightsMetricsResultToFrame(t *testing.T) {
}, },
} }
for _, tt := range tests { for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
res, err := loadInsightsMetricsResponse(tt.testFile) res, err := loadInsightsMetricsResponse(tt.testFile)
require.NoError(t, err) require.NoError(t, err)

@ -69,7 +69,6 @@ func TestBuildingAzureLogAnalyticsQueries(t *testing.T) {
} }
for _, tt := range tests { for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
queries, err := datasource.buildQueries(tt.queryModel, tt.timeRange) queries, err := datasource.buildQueries(tt.queryModel, tt.timeRange)
tt.Err(t, err) tt.Err(t, err)
@ -142,7 +141,6 @@ func TestPluginRoutes(t *testing.T) {
} }
for _, tt := range tests { for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
route, proxypass, err := datasource.getPluginRoute(plugin, tt.cloudName) route, proxypass, err := datasource.getPluginRoute(plugin, tt.cloudName)
tt.Err(t, err) tt.Err(t, err)

@ -122,7 +122,6 @@ func TestLogTableToFrame(t *testing.T) {
} }
for _, tt := range tests { for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
res, err := loadLogAnalyticsTestFileWithNumber(tt.testFile) res, err := loadLogAnalyticsTestFileWithNumber(tt.testFile)
require.NoError(t, err) require.NoError(t, err)

@ -98,7 +98,6 @@ func TestAzureMonitorBuildQueries(t *testing.T) {
} }
for _, tt := range tests { for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
for k, v := range commonAzureModelProps { for k, v := range commonAzureModelProps {
tt.azureMonitorVariedProperties[k] = v tt.azureMonitorVariedProperties[k] = v
@ -364,7 +363,6 @@ func TestAzureMonitorParseResponse(t *testing.T) {
datasource := &AzureMonitorDatasource{} datasource := &AzureMonitorDatasource{}
for _, tt := range tests { for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
azData, err := loadTestFile("azuremonitor/" + tt.responseFile) azData, err := loadTestFile("azuremonitor/" + tt.responseFile)
require.NoError(t, err) require.NoError(t, err)
@ -422,7 +420,6 @@ func TestFindClosestAllowIntervalMS(t *testing.T) {
}, },
} }
for _, tt := range tests { for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
interval := findClosestAllowedIntervalMS(tt.inputInterval, tt.allowedTimeGrains) interval := findClosestAllowedIntervalMS(tt.inputInterval, tt.allowedTimeGrains)
require.Equal(t, tt.expectedInterval, interval) require.Equal(t, tt.expectedInterval, interval)

@ -139,7 +139,6 @@ func TestAzureLogAnalyticsMacros(t *testing.T) {
} }
for _, tt := range tests { for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
defaultTimeField := "TimeGenerated" defaultTimeField := "TimeGenerated"
rawQuery, err := KqlInterpolate(tt.query, timeRange, tt.kql, defaultTimeField) rawQuery, err := KqlInterpolate(tt.query, timeRange, tt.kql, defaultTimeField)

@ -128,7 +128,6 @@ func TestFrameToSeriesSlice(t *testing.T) {
}, },
} }
for _, tt := range tests { for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
seriesSlice, err := FrameToSeriesSlice(tt.frame) seriesSlice, err := FrameToSeriesSlice(tt.frame)
tt.Err(t, err) tt.Err(t, err)

@ -35,7 +35,6 @@ func TestInterpolate(t *testing.T) {
}, },
} }
for _, tt := range tests { for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
query := QueryModel{ query := QueryModel{

@ -44,6 +44,10 @@ enable = [
# "gocyclo", # "gocyclo",
# "unparam" # "unparam"
[[issues.exclude-rules]]
path = "_test\\.go"
linters = ["scopelint"]
[[issues.exclude-rules]] [[issues.exclude-rules]]
linters = ["gosec"] linters = ["gosec"]
text = "G108" text = "G108"

@ -11,6 +11,10 @@ min-occurrences = 5
[linters] [linters]
disable-all = true disable-all = true
[[issues.exclude-rules]]
path = "_test\\.go"
linters = ["scopelint"]
[[issues.exclude-rules]] [[issues.exclude-rules]]
linters = ["gosec"] linters = ["gosec"]
text = "G108" text = "G108"

Loading…
Cancel
Save