MM-61450 fix errcheck issue in server/channel/app/permissions_test.go (#31132)

Этот коммит содержится в:
Akhil Bisht
2025-06-05 23:13:40 +05:30
коммит произвёл GitHub
родитель f2aa50170f
Коммит 4e337b9a43
2 изменённых файлов: 11 добавлений и 8 удалений

Просмотреть файл

@@ -111,7 +111,6 @@ linters:
channels/app/bot_test.go|\
channels/app/file_test.go|\
channels/app/helper_test.go|\
channels/app/permissions_test.go|\
channels/app/platform/helper_test.go|\
channels/store/localcachelayer/channel_layer.go|\
channels/store/localcachelayer/channel_layer_test.go|\
@@ -243,4 +242,4 @@ formatters:
- mock.*
issues:
max-issues-per-linter: 0 # no maximum
max-same-issues: 0 # no maximum
max-same-issues: 0 # no maximum

Просмотреть файл

@@ -29,7 +29,7 @@ func TestExportPermissions(t *testing.T) {
var scheme *model.Scheme
var roles []*model.Role
withMigrationMarkedComplete(th, func() {
withMigrationMarkedComplete(t, th, func() {
scheme, roles = th.CreateScheme()
})
@@ -102,7 +102,8 @@ func TestMigration(t *testing.T) {
assert.Contains(t, role.Permissions, model.PermissionDeleteOthersEmojis.Id)
assert.Contains(t, role.Permissions, model.PermissionUseGroupMentions.Id)
th.App.ResetPermissionsSystem()
appErr := th.App.ResetPermissionsSystem()
require.Nil(t, appErr)
role, err = th.App.GetRoleByName(context.Background(), model.SystemAdminRoleId)
require.Nil(t, err)
@@ -112,13 +113,16 @@ func TestMigration(t *testing.T) {
assert.Contains(t, role.Permissions, model.PermissionUseGroupMentions.Id)
}
func withMigrationMarkedComplete(th *TestHelper, f func()) {
func withMigrationMarkedComplete(t *testing.T, th *TestHelper, f func()) {
// Mark the migration as done.
th.App.Srv().Store().System().PermanentDeleteByName(model.MigrationKeyAdvancedPermissionsPhase2)
th.App.Srv().Store().System().Save(&model.System{Name: model.MigrationKeyAdvancedPermissionsPhase2, Value: "true"})
_, err := th.App.Srv().Store().System().PermanentDeleteByName(model.MigrationKeyAdvancedPermissionsPhase2)
require.NoError(t, err)
err = th.App.Srv().Store().System().Save(&model.System{Name: model.MigrationKeyAdvancedPermissionsPhase2, Value: "true"})
require.NoError(t, err)
// Un-mark the migration at the end of the test.
defer func() {
th.App.Srv().Store().System().PermanentDeleteByName(model.MigrationKeyAdvancedPermissionsPhase2)
_, err := th.App.Srv().Store().System().PermanentDeleteByName(model.MigrationKeyAdvancedPermissionsPhase2)
require.NoError(t, err)
}()
f()
}