From 4e337b9a434143515b041a9f6ac8667da386aa7e Mon Sep 17 00:00:00 2001 From: Akhil Bisht <92508481+Akhilbisht798@users.noreply.github.com> Date: Thu, 5 Jun 2025 23:13:40 +0530 Subject: [PATCH] MM-61450 fix errcheck issue in server/channel/app/permissions_test.go (#31132) --- server/.golangci.yml | 3 +-- server/channels/app/permissions_test.go | 16 ++++++++++------ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/server/.golangci.yml b/server/.golangci.yml index 012ab77bf0..296278763a 100644 --- a/server/.golangci.yml +++ b/server/.golangci.yml @@ -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 \ No newline at end of file diff --git a/server/channels/app/permissions_test.go b/server/channels/app/permissions_test.go index 52d8aecd3e..aac487f65a 100644 --- a/server/channels/app/permissions_test.go +++ b/server/channels/app/permissions_test.go @@ -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() }