From ccf5916ef03bad489726678d96d90c6da54c6991 Mon Sep 17 00:00:00 2001 From: Choo Jia Le <5955220+jials@users.noreply.github.com> Date: Thu, 5 Nov 2020 19:45:41 +0800 Subject: [PATCH] [MM-24337]: Fix the team and channel filtering UT to include empty team or channel (#15912) * Fix the team and channel filtering UT to include empty team or channel * Fix tests that were failing before this change Once we've activated the team/channels filter tests for PostgreSQL and MySQL there are some tests failing so this changes fixes them * Disable team filtering tests for DBs by now We have a discrepancy between DB search and ES/Bleve on how to filter teams when you have users in both teams: - DB when filtering by one team and searching by another returns users that are in both teams - Bleve and ES returns empty Co-authored-by: Mario de Frutos Co-authored-by: Mattermod --- store/searchtest/user_layer.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/store/searchtest/user_layer.go b/store/searchtest/user_layer.go index fdc1737d67..7fb85b250b 100644 --- a/store/searchtest/user_layer.go +++ b/store/searchtest/user_layer.go @@ -20,7 +20,7 @@ var searchUserStoreTests = []searchTest{ { Name: "Should honor channel restrictions when autocompleting users", Fn: testHonorChannelRestrictionsAutocompletingUsers, - Tags: []string{ENGINE_ELASTICSEARCH, ENGINE_BLEVE}, + Tags: []string{ENGINE_ALL}, }, { Name: "Should honor team restrictions when autocompleting users", @@ -238,7 +238,7 @@ func testHonorChannelRestrictionsAutocompletingUsers(t *testing.T, th *SearchTes }) t.Run("Autocomplete users with all channels restricted", func(t *testing.T) { options := createDefaultOptions(true, false, false) - options.ViewRestrictions = &model.ViewUsersRestrictions{Channels: []string{}} + options.ViewRestrictions = &model.ViewUsersRestrictions{Teams: []string{}, Channels: []string{}} users, apperr := th.Store.User().AutocompleteUsersInChannel(th.Team.Id, th.ChannelBasic.Id, "", options) require.Nil(t, apperr) th.assertUsersMatchInAnyOrder(t, []*model.User{}, users.InChannel) @@ -246,7 +246,7 @@ func testHonorChannelRestrictionsAutocompletingUsers(t *testing.T, th *SearchTes }) t.Run("Autocomplete users with all channels restricted but with empty team", func(t *testing.T) { options := createDefaultOptions(true, false, false) - options.ViewRestrictions = &model.ViewUsersRestrictions{Channels: []string{}} + options.ViewRestrictions = &model.ViewUsersRestrictions{Teams: []string{}, Channels: []string{}} users, apperr := th.Store.User().AutocompleteUsersInChannel("", th.ChannelBasic.Id, "", options) require.Nil(t, apperr) th.assertUsersMatchInAnyOrder(t, []*model.User{}, users.InChannel) @@ -273,7 +273,7 @@ func testHonorTeamRestrictionsAutocompletingUsers(t *testing.T, th *SearchTestHe }) t.Run("Should return empty because we're filtering all the teams", func(t *testing.T) { options := createDefaultOptions(true, false, false) - options.ViewRestrictions = &model.ViewUsersRestrictions{Teams: []string{}} + options.ViewRestrictions = &model.ViewUsersRestrictions{Teams: []string{}, Channels: []string{}} users, apperr := th.Store.User().AutocompleteUsersInChannel(th.Team.Id, th.ChannelBasic.Id, "", options) require.Nil(t, apperr) th.assertUsersMatchInAnyOrder(t, []*model.User{}, users.InChannel)