diff --git a/server/.golangci.yml b/server/.golangci.yml index ad2998a34d..fab93c4da4 100644 --- a/server/.golangci.yml +++ b/server/.golangci.yml @@ -152,7 +152,6 @@ issues: channels/app/upload_test.go|\ channels/app/user.go|\ channels/app/user_test.go|\ - channels/app/user_viewmembers_test.go|\ channels/app/users/helper_test.go|\ channels/app/users/users_test.go|\ channels/app/web_broadcast_hooks_test.go|\ diff --git a/server/channels/app/user_viewmembers_test.go b/server/channels/app/user_viewmembers_test.go index 93e8df2ad6..4bdf4b21d0 100644 --- a/server/channels/app/user_viewmembers_test.go +++ b/server/channels/app/user_viewmembers_test.go @@ -20,23 +20,28 @@ func TestRestrictedViewMembers(t *testing.T) { user1 := th.CreateUser() user1.Nickname = "test user1" user1.Username = "test-user-1" - th.App.UpdateUser(th.Context, user1, false) + _, appErr := th.App.UpdateUser(th.Context, user1, false) + require.Nil(t, appErr) user2 := th.CreateUser() user2.Username = "test-user-2" user2.Nickname = "test user2" - th.App.UpdateUser(th.Context, user2, false) + _, appErr = th.App.UpdateUser(th.Context, user2, false) + require.Nil(t, appErr) user3 := th.CreateUser() user3.Username = "test-user-3" user3.Nickname = "test user3" - th.App.UpdateUser(th.Context, user3, false) + _, appErr = th.App.UpdateUser(th.Context, user3, false) + require.Nil(t, appErr) user4 := th.CreateUser() user4.Username = "test-user-4" user4.Nickname = "test user4" - th.App.UpdateUser(th.Context, user4, false) + _, appErr = th.App.UpdateUser(th.Context, user4, false) + require.Nil(t, appErr) user5 := th.CreateUser() user5.Username = "test-user-5" user5.Nickname = "test user5" - th.App.UpdateUser(th.Context, user5, false) + _, appErr = th.App.UpdateUser(th.Context, user5, false) + require.Nil(t, appErr) // user1 is member of all the channels and teams because is the creator th.BasicUser = user1 @@ -131,8 +136,8 @@ func TestRestrictedViewMembers(t *testing.T) { for _, tc := range testCases { t.Run(tc.Name, func(t *testing.T) { options := model.UserSearchOptions{Limit: 100, ViewRestrictions: tc.Restrictions} - results, err := th.App.SearchUsers(th.Context, &tc.Search, &options) - require.Nil(t, err) + results, appErr := th.App.SearchUsers(th.Context, &tc.Search, &options) + require.Nil(t, appErr) ids := []string{} for _, result := range results { ids = append(ids, result.Id) @@ -207,8 +212,8 @@ func TestRestrictedViewMembers(t *testing.T) { for _, tc := range testCases { t.Run(tc.Name, func(t *testing.T) { options := model.UserSearchOptions{Limit: 100, ViewRestrictions: tc.Restrictions} - results, err := th.App.SearchUsersInTeam(th.Context, tc.TeamId, "test", &options) - require.Nil(t, err) + results, appErr := th.App.SearchUsersInTeam(th.Context, tc.TeamId, "test", &options) + require.Nil(t, appErr) ids := []string{} for _, result := range results { ids = append(ids, result.Id) @@ -283,8 +288,8 @@ func TestRestrictedViewMembers(t *testing.T) { for _, tc := range testCases { t.Run(tc.Name, func(t *testing.T) { options := model.UserSearchOptions{Limit: 100, ViewRestrictions: tc.Restrictions} - results, err := th.App.AutocompleteUsersInTeam(th.Context, tc.TeamId, "tes", &options) - require.Nil(t, err) + results, appErr := th.App.AutocompleteUsersInTeam(th.Context, tc.TeamId, "tes", &options) + require.Nil(t, appErr) ids := []string{} for _, result := range results.InTeam { ids = append(ids, result.Id) @@ -367,8 +372,8 @@ func TestRestrictedViewMembers(t *testing.T) { for _, tc := range testCases { t.Run(tc.Name, func(t *testing.T) { options := model.UserSearchOptions{Limit: 100, ViewRestrictions: tc.Restrictions} - results, err := th.App.AutocompleteUsersInChannel(th.Context, tc.TeamId, tc.ChannelId, "tes", &options) - require.Nil(t, err) + results, appErr := th.App.AutocompleteUsersInChannel(th.Context, tc.TeamId, tc.ChannelId, "tes", &options) + require.Nil(t, appErr) ids := []string{} for _, result := range results.InChannel { ids = append(ids, result.Id) @@ -442,8 +447,8 @@ func TestRestrictedViewMembers(t *testing.T) { for _, tc := range testCases { t.Run(tc.Name, func(t *testing.T) { - results, err := th.App.GetNewUsersForTeamPage(th.Context, tc.TeamId, 0, 2, false, tc.Restrictions) - require.Nil(t, err) + results, appErr := th.App.GetNewUsersForTeamPage(th.Context, tc.TeamId, 0, 2, false, tc.Restrictions) + require.Nil(t, appErr) ids := []string{} for _, result := range results { ids = append(ids, result.Id) @@ -517,16 +522,16 @@ func TestRestrictedViewMembers(t *testing.T) { for _, tc := range testCases { t.Run(tc.Name, func(t *testing.T) { - results, err := th.App.GetRecentlyActiveUsersForTeamPage(th.Context, tc.TeamId, 0, 3, false, tc.Restrictions) - require.Nil(t, err) + results, appErr := th.App.GetRecentlyActiveUsersForTeamPage(th.Context, tc.TeamId, 0, 3, false, tc.Restrictions) + require.Nil(t, appErr) ids := []string{} for _, result := range results { ids = append(ids, result.Id) } assert.ElementsMatch(t, tc.ExpectedResults, ids) - results, err = th.App.GetRecentlyActiveUsersForTeamPage(th.Context, tc.TeamId, 0, 1, false, tc.Restrictions) - require.Nil(t, err) + results, appErr = th.App.GetRecentlyActiveUsersForTeamPage(th.Context, tc.TeamId, 0, 1, false, tc.Restrictions) + require.Nil(t, appErr) if len(tc.ExpectedResults) > 1 { assert.Len(t, results, 1) } else { @@ -574,8 +579,8 @@ func TestRestrictedViewMembers(t *testing.T) { for _, tc := range testCases { t.Run(tc.Name, func(t *testing.T) { options := model.UserGetOptions{Page: 0, PerPage: 100, ViewRestrictions: tc.Restrictions} - results, err := th.App.GetUsersFromProfiles(&options) - require.Nil(t, err) + results, appErr := th.App.GetUsersFromProfiles(&options) + require.Nil(t, appErr) ids := []string{} for _, result := range results { ids = append(ids, result.Id) @@ -622,8 +627,8 @@ func TestRestrictedViewMembers(t *testing.T) { for _, tc := range testCases { t.Run(tc.Name, func(t *testing.T) { - results, err := th.App.GetUsersWithoutTeam(&model.UserGetOptions{Page: 0, PerPage: 100, ViewRestrictions: tc.Restrictions}) - require.Nil(t, err) + results, appErr := th.App.GetUsersWithoutTeam(&model.UserGetOptions{Page: 0, PerPage: 100, ViewRestrictions: tc.Restrictions}) + require.Nil(t, appErr) ids := []string{} for _, result := range results { ids = append(ids, result.Id) @@ -697,8 +702,8 @@ func TestRestrictedViewMembers(t *testing.T) { for _, tc := range testCases { t.Run(tc.Name, func(t *testing.T) { - results, err := th.App.GetUsersNotInTeam(tc.TeamId, false, 0, 100, tc.Restrictions) - require.Nil(t, err) + results, appErr := th.App.GetUsersNotInTeam(tc.TeamId, false, 0, 100, tc.Restrictions) + require.Nil(t, appErr) ids := []string{} for _, result := range results { ids = append(ids, result.Id) @@ -780,8 +785,8 @@ func TestRestrictedViewMembers(t *testing.T) { for _, tc := range testCases { t.Run(tc.Name, func(t *testing.T) { - results, err := th.App.GetUsersNotInChannel(tc.TeamId, tc.ChannelId, false, 0, 100, tc.Restrictions) - require.Nil(t, err) + results, appErr := th.App.GetUsersNotInChannel(tc.TeamId, tc.ChannelId, false, 0, 100, tc.Restrictions) + require.Nil(t, appErr) ids := []string{} for _, result := range results { ids = append(ids, result.Id) @@ -833,11 +838,11 @@ func TestRestrictedViewMembers(t *testing.T) { for _, tc := range testCases { t.Run(tc.Name, func(t *testing.T) { - results, err := th.App.GetUsersByIds(tc.UserIds, &store.UserGetByIdsOpts{ + results, appErr := th.App.GetUsersByIds(tc.UserIds, &store.UserGetByIdsOpts{ IsAdmin: false, ViewRestrictions: tc.Restrictions, }) - require.Nil(t, err) + require.Nil(t, appErr) ids := []string{} for _, result := range results { ids = append(ids, result.Id) @@ -889,8 +894,8 @@ func TestRestrictedViewMembers(t *testing.T) { for _, tc := range testCases { t.Run(tc.Name, func(t *testing.T) { - results, err := th.App.GetUsersByUsernames(tc.Usernames, false, tc.Restrictions) - require.Nil(t, err) + results, appErr := th.App.GetUsersByUsernames(tc.Usernames, false, tc.Restrictions) + require.Nil(t, appErr) ids := []string{} for _, result := range results { ids = append(ids, result.Id) @@ -937,8 +942,8 @@ func TestRestrictedViewMembers(t *testing.T) { for _, tc := range testCases { t.Run(tc.Name, func(t *testing.T) { - result, err := th.App.GetTotalUsersStats(tc.Restrictions) - require.Nil(t, err) + result, appErr := th.App.GetTotalUsersStats(tc.Restrictions) + require.Nil(t, appErr) assert.Equal(t, tc.ExpectedResult, result.TotalUsersCount) }) } @@ -1011,8 +1016,8 @@ func TestRestrictedViewMembers(t *testing.T) { getTeamMemberOptions := &model.TeamMembersGetOptions{ ViewRestrictions: tc.Restrictions, } - results, err := th.App.GetTeamMembers(tc.TeamId, 0, 100, getTeamMemberOptions) - require.Nil(t, err) + results, appErr := th.App.GetTeamMembers(tc.TeamId, 0, 100, getTeamMemberOptions) + require.Nil(t, appErr) ids := []string{} for _, result := range results { ids = append(ids, result.UserId) @@ -1094,8 +1099,8 @@ func TestRestrictedViewMembers(t *testing.T) { for _, tc := range testCases { t.Run(tc.Name, func(t *testing.T) { - results, err := th.App.GetTeamMembersByIds(tc.TeamId, tc.UserIds, tc.Restrictions) - require.Nil(t, err) + results, appErr := th.App.GetTeamMembersByIds(tc.TeamId, tc.UserIds, tc.Restrictions) + require.Nil(t, appErr) ids := []string{} for _, result := range results { ids = append(ids, result.UserId)