[MM-55595] Use annotated logger in search layer (#25468)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
5a4dba8809
Коммит
b2ec1ff8ae
@@ -10,6 +10,7 @@ import (
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/mattermost/mattermost/server/public/model"
|
||||
"github.com/mattermost/mattermost/server/public/shared/request"
|
||||
"github.com/mattermost/mattermost/server/v8/channels/store"
|
||||
)
|
||||
|
||||
@@ -186,7 +187,8 @@ var searchFileInfoStoreTests = []searchTest{
|
||||
|
||||
func TestSearchFileInfoStore(t *testing.T, s store.Store, testEngine *SearchTestEngine) {
|
||||
th := &SearchTestHelper{
|
||||
Store: s,
|
||||
Context: request.TestContext(t),
|
||||
Store: s,
|
||||
}
|
||||
err := th.SetupBasicFixtures()
|
||||
require.NoError(t, err)
|
||||
@@ -217,7 +219,7 @@ func testFileInfoSearchFileInfosIncludingDMs(t *testing.T, th *SearchTestHelper)
|
||||
|
||||
t.Run("by-name", func(t *testing.T) {
|
||||
params := &model.SearchParams{Terms: "test"}
|
||||
results, err := th.Store.FileInfo().Search([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
results, err := th.Store.FileInfo().Search(th.Context, []*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Len(t, results.FileInfos, 2)
|
||||
@@ -227,7 +229,7 @@ func testFileInfoSearchFileInfosIncludingDMs(t *testing.T, th *SearchTestHelper)
|
||||
|
||||
t.Run("by-content", func(t *testing.T) {
|
||||
params := &model.SearchParams{Terms: "contenttest"}
|
||||
results, err := th.Store.FileInfo().Search([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
results, err := th.Store.FileInfo().Search(th.Context, []*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Len(t, results.FileInfos, 2)
|
||||
@@ -258,13 +260,13 @@ func testFileInfoSearchFileInfosWithPagination(t *testing.T, th *SearchTestHelpe
|
||||
|
||||
t.Run("by-name", func(t *testing.T) {
|
||||
params := &model.SearchParams{Terms: "test"}
|
||||
results, err := th.Store.FileInfo().Search([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 1)
|
||||
results, err := th.Store.FileInfo().Search(th.Context, []*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 1)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Len(t, results.FileInfos, 1)
|
||||
th.checkFileInfoInSearchResults(t, p2.Id, results.FileInfos)
|
||||
|
||||
results, err = th.Store.FileInfo().Search([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 1, 1)
|
||||
results, err = th.Store.FileInfo().Search(th.Context, []*model.SearchParams{params}, th.User.Id, th.Team.Id, 1, 1)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Len(t, results.FileInfos, 1)
|
||||
@@ -273,13 +275,13 @@ func testFileInfoSearchFileInfosWithPagination(t *testing.T, th *SearchTestHelpe
|
||||
|
||||
t.Run("by-content", func(t *testing.T) {
|
||||
params := &model.SearchParams{Terms: "contenttest"}
|
||||
results, err := th.Store.FileInfo().Search([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 1)
|
||||
results, err := th.Store.FileInfo().Search(th.Context, []*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 1)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Len(t, results.FileInfos, 1)
|
||||
th.checkFileInfoInSearchResults(t, p2.Id, results.FileInfos)
|
||||
|
||||
results, err = th.Store.FileInfo().Search([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 1, 1)
|
||||
results, err = th.Store.FileInfo().Search(th.Context, []*model.SearchParams{params}, th.User.Id, th.Team.Id, 1, 1)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Len(t, results.FileInfos, 1)
|
||||
@@ -300,7 +302,7 @@ func testFileInfoSearchExactPhraseInQuotes(t *testing.T, th *SearchTestHelper) {
|
||||
|
||||
t.Run("by-name", func(t *testing.T) {
|
||||
params := &model.SearchParams{Terms: "\"channel test 1 2 3\""}
|
||||
results, err := th.Store.FileInfo().Search([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
results, err := th.Store.FileInfo().Search(th.Context, []*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Len(t, results.FileInfos, 1)
|
||||
@@ -309,7 +311,7 @@ func testFileInfoSearchExactPhraseInQuotes(t *testing.T, th *SearchTestHelper) {
|
||||
|
||||
t.Run("by-content", func(t *testing.T) {
|
||||
params := &model.SearchParams{Terms: "\"channel content test 1 2 3\""}
|
||||
results, err := th.Store.FileInfo().Search([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
results, err := th.Store.FileInfo().Search(th.Context, []*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Len(t, results.FileInfos, 1)
|
||||
@@ -331,7 +333,7 @@ func testFileInfoSearchEmailAddresses(t *testing.T, th *SearchTestHelper) {
|
||||
t.Run("by-name", func(t *testing.T) {
|
||||
t.Run("Should search email addresses enclosed by quotes", func(t *testing.T) {
|
||||
params := &model.SearchParams{Terms: "\"test@test.com\""}
|
||||
results, err := th.Store.FileInfo().Search([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
results, err := th.Store.FileInfo().Search(th.Context, []*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Len(t, results.FileInfos, 1)
|
||||
@@ -340,7 +342,7 @@ func testFileInfoSearchEmailAddresses(t *testing.T, th *SearchTestHelper) {
|
||||
|
||||
t.Run("Should search email addresses without quotes", func(t *testing.T) {
|
||||
params := &model.SearchParams{Terms: "test@test.com"}
|
||||
results, err := th.Store.FileInfo().Search([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
results, err := th.Store.FileInfo().Search(th.Context, []*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Len(t, results.FileInfos, 1)
|
||||
@@ -350,7 +352,7 @@ func testFileInfoSearchEmailAddresses(t *testing.T, th *SearchTestHelper) {
|
||||
t.Run("by-content", func(t *testing.T) {
|
||||
t.Run("Should search email addresses enclosed by quotes", func(t *testing.T) {
|
||||
params := &model.SearchParams{Terms: "\"test@content.com\""}
|
||||
results, err := th.Store.FileInfo().Search([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
results, err := th.Store.FileInfo().Search(th.Context, []*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Len(t, results.FileInfos, 1)
|
||||
@@ -359,7 +361,7 @@ func testFileInfoSearchEmailAddresses(t *testing.T, th *SearchTestHelper) {
|
||||
|
||||
t.Run("Should search email addresses without quotes", func(t *testing.T) {
|
||||
params := &model.SearchParams{Terms: "test@content.com"}
|
||||
results, err := th.Store.FileInfo().Search([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
results, err := th.Store.FileInfo().Search(th.Context, []*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Len(t, results.FileInfos, 1)
|
||||
@@ -379,7 +381,7 @@ func testFileInfoSearchMarkdownUnderscores(t *testing.T, th *SearchTestHelper) {
|
||||
|
||||
t.Run("Should search the start inside the markdown underscore", func(t *testing.T) {
|
||||
params := &model.SearchParams{Terms: "start"}
|
||||
results, err := th.Store.FileInfo().Search([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
results, err := th.Store.FileInfo().Search(th.Context, []*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Len(t, results.FileInfos, 1)
|
||||
@@ -388,7 +390,7 @@ func testFileInfoSearchMarkdownUnderscores(t *testing.T, th *SearchTestHelper) {
|
||||
|
||||
t.Run("Should search a word in the middle of the markdown underscore", func(t *testing.T) {
|
||||
params := &model.SearchParams{Terms: "middle"}
|
||||
results, err := th.Store.FileInfo().Search([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
results, err := th.Store.FileInfo().Search(th.Context, []*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Len(t, results.FileInfos, 1)
|
||||
@@ -397,7 +399,7 @@ func testFileInfoSearchMarkdownUnderscores(t *testing.T, th *SearchTestHelper) {
|
||||
|
||||
t.Run("Should search in the end of the markdown underscore", func(t *testing.T) {
|
||||
params := &model.SearchParams{Terms: "end"}
|
||||
results, err := th.Store.FileInfo().Search([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
results, err := th.Store.FileInfo().Search(th.Context, []*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Len(t, results.FileInfos, 1)
|
||||
@@ -406,7 +408,7 @@ func testFileInfoSearchMarkdownUnderscores(t *testing.T, th *SearchTestHelper) {
|
||||
|
||||
t.Run("Should search inside markdown underscore", func(t *testing.T) {
|
||||
params := &model.SearchParams{Terms: "another"}
|
||||
results, err := th.Store.FileInfo().Search([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
results, err := th.Store.FileInfo().Search(th.Context, []*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Len(t, results.FileInfos, 1)
|
||||
@@ -428,7 +430,7 @@ func testFileInfoSearchNonLatinWords(t *testing.T, th *SearchTestHelper) {
|
||||
|
||||
t.Run("Should search one word", func(t *testing.T) {
|
||||
params := &model.SearchParams{Terms: "你"}
|
||||
results, err := th.Store.FileInfo().Search([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
results, err := th.Store.FileInfo().Search(th.Context, []*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Len(t, results.FileInfos, 1)
|
||||
@@ -436,7 +438,7 @@ func testFileInfoSearchNonLatinWords(t *testing.T, th *SearchTestHelper) {
|
||||
})
|
||||
t.Run("Should search two words", func(t *testing.T) {
|
||||
params := &model.SearchParams{Terms: "你好"}
|
||||
results, err := th.Store.FileInfo().Search([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
results, err := th.Store.FileInfo().Search(th.Context, []*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Len(t, results.FileInfos, 1)
|
||||
@@ -444,7 +446,7 @@ func testFileInfoSearchNonLatinWords(t *testing.T, th *SearchTestHelper) {
|
||||
})
|
||||
t.Run("Should search with wildcard", func(t *testing.T) {
|
||||
params := &model.SearchParams{Terms: "你*"}
|
||||
results, err := th.Store.FileInfo().Search([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
results, err := th.Store.FileInfo().Search(th.Context, []*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Len(t, results.FileInfos, 2)
|
||||
@@ -459,7 +461,7 @@ func testFileInfoSearchNonLatinWords(t *testing.T, th *SearchTestHelper) {
|
||||
|
||||
t.Run("Should search one word", func(t *testing.T) {
|
||||
params := &model.SearchParams{Terms: "слово"}
|
||||
results, err := th.Store.FileInfo().Search([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
results, err := th.Store.FileInfo().Search(th.Context, []*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Len(t, results.FileInfos, 1)
|
||||
@@ -467,7 +469,7 @@ func testFileInfoSearchNonLatinWords(t *testing.T, th *SearchTestHelper) {
|
||||
})
|
||||
t.Run("Should search using wildcard", func(t *testing.T) {
|
||||
params := &model.SearchParams{Terms: "слов*"}
|
||||
results, err := th.Store.FileInfo().Search([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
results, err := th.Store.FileInfo().Search(th.Context, []*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Len(t, results.FileInfos, 1)
|
||||
@@ -484,7 +486,7 @@ func testFileInfoSearchNonLatinWords(t *testing.T, th *SearchTestHelper) {
|
||||
|
||||
t.Run("Should search one word", func(t *testing.T) {
|
||||
params := &model.SearchParams{Terms: "本"}
|
||||
results, err := th.Store.FileInfo().Search([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
results, err := th.Store.FileInfo().Search(th.Context, []*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Len(t, results.FileInfos, 2)
|
||||
@@ -493,7 +495,7 @@ func testFileInfoSearchNonLatinWords(t *testing.T, th *SearchTestHelper) {
|
||||
})
|
||||
t.Run("Should search two words", func(t *testing.T) {
|
||||
params := &model.SearchParams{Terms: "本木"}
|
||||
results, err := th.Store.FileInfo().Search([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
results, err := th.Store.FileInfo().Search(th.Context, []*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Len(t, results.FileInfos, 1)
|
||||
@@ -501,7 +503,7 @@ func testFileInfoSearchNonLatinWords(t *testing.T, th *SearchTestHelper) {
|
||||
})
|
||||
t.Run("Should search with wildcard", func(t *testing.T) {
|
||||
params := &model.SearchParams{Terms: "本*"}
|
||||
results, err := th.Store.FileInfo().Search([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
results, err := th.Store.FileInfo().Search(th.Context, []*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Len(t, results.FileInfos, 2)
|
||||
@@ -519,7 +521,7 @@ func testFileInfoSearchNonLatinWords(t *testing.T, th *SearchTestHelper) {
|
||||
|
||||
t.Run("Should search one word", func(t *testing.T) {
|
||||
params := &model.SearchParams{Terms: "불"}
|
||||
results, err := th.Store.FileInfo().Search([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
results, err := th.Store.FileInfo().Search(th.Context, []*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Len(t, results.FileInfos, 1)
|
||||
@@ -527,7 +529,7 @@ func testFileInfoSearchNonLatinWords(t *testing.T, th *SearchTestHelper) {
|
||||
})
|
||||
t.Run("Should search two words", func(t *testing.T) {
|
||||
params := &model.SearchParams{Terms: "불다"}
|
||||
results, err := th.Store.FileInfo().Search([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
results, err := th.Store.FileInfo().Search(th.Context, []*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Len(t, results.FileInfos, 1)
|
||||
@@ -535,7 +537,7 @@ func testFileInfoSearchNonLatinWords(t *testing.T, th *SearchTestHelper) {
|
||||
})
|
||||
t.Run("Should search with wildcard", func(t *testing.T) {
|
||||
params := &model.SearchParams{Terms: "불*"}
|
||||
results, err := th.Store.FileInfo().Search([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
results, err := th.Store.FileInfo().Search(th.Context, []*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Len(t, results.FileInfos, 2)
|
||||
@@ -557,7 +559,7 @@ func testFileInfoSearchAlternativeSpellings(t *testing.T, th *SearchTestHelper)
|
||||
defer th.deleteUserFileInfos(th.User.Id)
|
||||
|
||||
params := &model.SearchParams{Terms: "Straße"}
|
||||
results, err := th.Store.FileInfo().Search([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
results, err := th.Store.FileInfo().Search(th.Context, []*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Len(t, results.FileInfos, 2)
|
||||
@@ -565,7 +567,7 @@ func testFileInfoSearchAlternativeSpellings(t *testing.T, th *SearchTestHelper)
|
||||
th.checkFileInfoInSearchResults(t, p2.Id, results.FileInfos)
|
||||
|
||||
params = &model.SearchParams{Terms: "Strasse"}
|
||||
results, err = th.Store.FileInfo().Search([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
results, err = th.Store.FileInfo().Search(th.Context, []*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Len(t, results.FileInfos, 2)
|
||||
@@ -585,7 +587,7 @@ func testFileInfoSearchAlternativeSpellingsAccents(t *testing.T, th *SearchTestH
|
||||
defer th.deleteUserFileInfos(th.User.Id)
|
||||
|
||||
params := &model.SearchParams{Terms: "café"}
|
||||
results, err := th.Store.FileInfo().Search([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
results, err := th.Store.FileInfo().Search(th.Context, []*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Len(t, results.FileInfos, 2)
|
||||
@@ -593,7 +595,7 @@ func testFileInfoSearchAlternativeSpellingsAccents(t *testing.T, th *SearchTestH
|
||||
th.checkFileInfoInSearchResults(t, p2.Id, results.FileInfos)
|
||||
|
||||
params = &model.SearchParams{Terms: "café"}
|
||||
results, err = th.Store.FileInfo().Search([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
results, err = th.Store.FileInfo().Search(th.Context, []*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Len(t, results.FileInfos, 2)
|
||||
@@ -601,7 +603,7 @@ func testFileInfoSearchAlternativeSpellingsAccents(t *testing.T, th *SearchTestH
|
||||
th.checkFileInfoInSearchResults(t, p2.Id, results.FileInfos)
|
||||
|
||||
params = &model.SearchParams{Terms: "cafe"}
|
||||
results, err = th.Store.FileInfo().Search([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
results, err = th.Store.FileInfo().Search(th.Context, []*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Len(t, results.FileInfos, 0)
|
||||
@@ -620,7 +622,7 @@ func testFileInfoSearchOrExcludeFileInfosBySpecificUser(t *testing.T, th *Search
|
||||
defer th.deleteUserFileInfos(th.User2.Id)
|
||||
|
||||
params := &model.SearchParams{Terms: "fromuser", FromUsers: []string{th.User.Id}}
|
||||
results, err := th.Store.FileInfo().Search([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
results, err := th.Store.FileInfo().Search(th.Context, []*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Len(t, results.FileInfos, 1)
|
||||
@@ -643,7 +645,7 @@ func testFileInfoSearchOrExcludeFileInfosInChannel(t *testing.T, th *SearchTestH
|
||||
defer th.deleteUserFileInfos(th.User2.Id)
|
||||
|
||||
params := &model.SearchParams{Terms: "fromuser", InChannels: []string{th.ChannelBasic.Id}}
|
||||
results, err := th.Store.FileInfo().Search([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
results, err := th.Store.FileInfo().Search(th.Context, []*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Len(t, results.FileInfos, 1)
|
||||
@@ -678,7 +680,7 @@ func testFileInfoSearchOrExcludeFileInfosInDMGM(t *testing.T, th *SearchTestHelp
|
||||
Terms: "fromuser",
|
||||
InChannels: []string{direct.Id, group.Id},
|
||||
}
|
||||
results, err := th.Store.FileInfo().Search([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
results, err := th.Store.FileInfo().Search(th.Context, []*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Len(t, results.FileInfos, 2)
|
||||
@@ -691,7 +693,7 @@ func testFileInfoSearchOrExcludeFileInfosInDMGM(t *testing.T, th *SearchTestHelp
|
||||
Terms: "fromuser",
|
||||
InChannels: []string{direct.Id},
|
||||
}
|
||||
results, err := th.Store.FileInfo().Search([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
results, err := th.Store.FileInfo().Search(th.Context, []*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Len(t, results.FileInfos, 1)
|
||||
@@ -703,7 +705,7 @@ func testFileInfoSearchOrExcludeFileInfosInDMGM(t *testing.T, th *SearchTestHelp
|
||||
Terms: "fromuser",
|
||||
InChannels: []string{group.Id},
|
||||
}
|
||||
results, err := th.Store.FileInfo().Search([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
results, err := th.Store.FileInfo().Search(th.Context, []*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Len(t, results.FileInfos, 1)
|
||||
@@ -730,7 +732,7 @@ func testFileInfoSearchOrExcludeByExtensions(t *testing.T, th *SearchTestHelper)
|
||||
InChannels: []string{th.ChannelBasic.Id},
|
||||
Extensions: []string{"jpg"},
|
||||
}
|
||||
results, err := th.Store.FileInfo().Search([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
results, err := th.Store.FileInfo().Search(th.Context, []*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Len(t, results.FileInfos, 1)
|
||||
@@ -743,7 +745,7 @@ func testFileInfoSearchOrExcludeByExtensions(t *testing.T, th *SearchTestHelper)
|
||||
InChannels: []string{th.ChannelBasic.Id},
|
||||
Extensions: []string{"jpg", "bmp"},
|
||||
}
|
||||
results, err := th.Store.FileInfo().Search([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
results, err := th.Store.FileInfo().Search(th.Context, []*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Len(t, results.FileInfos, 2)
|
||||
@@ -757,7 +759,7 @@ func testFileInfoSearchOrExcludeByExtensions(t *testing.T, th *SearchTestHelper)
|
||||
InChannels: []string{th.ChannelBasic.Id},
|
||||
ExcludedExtensions: []string{"jpg"},
|
||||
}
|
||||
results, err := th.Store.FileInfo().Search([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
results, err := th.Store.FileInfo().Search(th.Context, []*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Len(t, results.FileInfos, 2)
|
||||
@@ -771,7 +773,7 @@ func testFileInfoSearchOrExcludeByExtensions(t *testing.T, th *SearchTestHelper)
|
||||
InChannels: []string{th.ChannelBasic.Id},
|
||||
ExcludedExtensions: []string{"jpg", "bmp"},
|
||||
}
|
||||
results, err := th.Store.FileInfo().Search([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
results, err := th.Store.FileInfo().Search(th.Context, []*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Len(t, results.FileInfos, 1)
|
||||
@@ -802,7 +804,7 @@ func testFileInfoFilterFilesInSpecificDate(t *testing.T, th *SearchTestHelper) {
|
||||
Terms: "test",
|
||||
OnDate: "2020-03-22",
|
||||
}
|
||||
results, err := th.Store.FileInfo().Search([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
results, err := th.Store.FileInfo().Search(th.Context, []*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Len(t, results.FileInfos, 1)
|
||||
@@ -813,7 +815,7 @@ func testFileInfoFilterFilesInSpecificDate(t *testing.T, th *SearchTestHelper) {
|
||||
Terms: "test",
|
||||
ExcludedDate: "2020-03-22",
|
||||
}
|
||||
results, err := th.Store.FileInfo().Search([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
results, err := th.Store.FileInfo().Search(th.Context, []*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Len(t, results.FileInfos, 2)
|
||||
@@ -845,7 +847,7 @@ func testFileInfoFilterFilesBeforeSpecificDate(t *testing.T, th *SearchTestHelpe
|
||||
Terms: "test",
|
||||
BeforeDate: "2020-03-23",
|
||||
}
|
||||
results, err := th.Store.FileInfo().Search([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
results, err := th.Store.FileInfo().Search(th.Context, []*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Len(t, results.FileInfos, 2)
|
||||
@@ -858,7 +860,7 @@ func testFileInfoFilterFilesBeforeSpecificDate(t *testing.T, th *SearchTestHelpe
|
||||
Terms: "test",
|
||||
ExcludedBeforeDate: "2020-03-23",
|
||||
}
|
||||
results, err := th.Store.FileInfo().Search([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
results, err := th.Store.FileInfo().Search(th.Context, []*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Len(t, results.FileInfos, 1)
|
||||
@@ -889,7 +891,7 @@ func testFileInfoFilterFilesAfterSpecificDate(t *testing.T, th *SearchTestHelper
|
||||
Terms: "test",
|
||||
AfterDate: "2020-03-23",
|
||||
}
|
||||
results, err := th.Store.FileInfo().Search([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
results, err := th.Store.FileInfo().Search(th.Context, []*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Len(t, results.FileInfos, 1)
|
||||
@@ -901,7 +903,7 @@ func testFileInfoFilterFilesAfterSpecificDate(t *testing.T, th *SearchTestHelper
|
||||
Terms: "test",
|
||||
ExcludedAfterDate: "2020-03-23",
|
||||
}
|
||||
results, err := th.Store.FileInfo().Search([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
results, err := th.Store.FileInfo().Search(th.Context, []*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Len(t, results.FileInfos, 2)
|
||||
@@ -930,7 +932,7 @@ func testFileInfoFilterFilesWithATerm(t *testing.T, th *SearchTestHelper) {
|
||||
Terms: "one",
|
||||
ExcludedTerms: "five eight",
|
||||
}
|
||||
results, err := th.Store.FileInfo().Search([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
results, err := th.Store.FileInfo().Search(th.Context, []*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Len(t, results.FileInfos, 1)
|
||||
@@ -942,7 +944,7 @@ func testFileInfoFilterFilesWithATerm(t *testing.T, th *SearchTestHelper) {
|
||||
Terms: "one",
|
||||
ExcludedTerms: "\"eight nine\"",
|
||||
}
|
||||
results, err := th.Store.FileInfo().Search([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
results, err := th.Store.FileInfo().Search(th.Context, []*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Len(t, results.FileInfos, 2)
|
||||
@@ -969,7 +971,7 @@ func testFileInfoSearchUsingBooleanOperators(t *testing.T, th *SearchTestHelper)
|
||||
Terms: "one two",
|
||||
OrTerms: true,
|
||||
}
|
||||
results, err := th.Store.FileInfo().Search([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
results, err := th.Store.FileInfo().Search(th.Context, []*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Len(t, results.FileInfos, 2)
|
||||
@@ -982,7 +984,7 @@ func testFileInfoSearchUsingBooleanOperators(t *testing.T, th *SearchTestHelper)
|
||||
Terms: "one two",
|
||||
OrTerms: false,
|
||||
}
|
||||
results, err := th.Store.FileInfo().Search([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
results, err := th.Store.FileInfo().Search(th.Context, []*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Len(t, results.FileInfos, 1)
|
||||
@@ -1015,7 +1017,7 @@ func testFileInfoSearchUsingCombinedFilters(t *testing.T, th *SearchTestHelper)
|
||||
FromUsers: []string{th.User2.Id},
|
||||
InChannels: []string{th.ChannelPrivate.Id},
|
||||
}
|
||||
results, err := th.Store.FileInfo().Search([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
results, err := th.Store.FileInfo().Search(th.Context, []*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Len(t, results.FileInfos, 1)
|
||||
@@ -1028,7 +1030,7 @@ func testFileInfoSearchUsingCombinedFilters(t *testing.T, th *SearchTestHelper)
|
||||
ExcludedUsers: []string{th.User2.Id},
|
||||
InChannels: []string{th.ChannelPrivate.Id},
|
||||
}
|
||||
results, err := th.Store.FileInfo().Search([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
results, err := th.Store.FileInfo().Search(th.Context, []*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Len(t, results.FileInfos, 1)
|
||||
@@ -1042,7 +1044,7 @@ func testFileInfoSearchUsingCombinedFilters(t *testing.T, th *SearchTestHelper)
|
||||
ExcludedAfterDate: "2020-03-11",
|
||||
InChannels: []string{th.ChannelPrivate.Id},
|
||||
}
|
||||
results, err := th.Store.FileInfo().Search([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
results, err := th.Store.FileInfo().Search(th.Context, []*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Len(t, results.FileInfos, 1)
|
||||
@@ -1054,7 +1056,7 @@ func testFileInfoSearchUsingCombinedFilters(t *testing.T, th *SearchTestHelper)
|
||||
AfterDate: "2020-03-11",
|
||||
ExcludedChannels: []string{th.ChannelPrivate.Id},
|
||||
}
|
||||
results, err := th.Store.FileInfo().Search([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
results, err := th.Store.FileInfo().Search(th.Context, []*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Len(t, results.FileInfos, 1)
|
||||
@@ -1081,7 +1083,7 @@ func testFileInfoSearchIgnoringStopWords(t *testing.T, th *SearchTestHelper) {
|
||||
params := &model.SearchParams{
|
||||
Terms: "the search",
|
||||
}
|
||||
results, err := th.Store.FileInfo().Search([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
results, err := th.Store.FileInfo().Search(th.Context, []*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Len(t, results.FileInfos, 1)
|
||||
@@ -1092,7 +1094,7 @@ func testFileInfoSearchIgnoringStopWords(t *testing.T, th *SearchTestHelper) {
|
||||
params := &model.SearchParams{
|
||||
Terms: "a avoid",
|
||||
}
|
||||
results, err := th.Store.FileInfo().Search([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
results, err := th.Store.FileInfo().Search(th.Context, []*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Len(t, results.FileInfos, 1)
|
||||
@@ -1103,7 +1105,7 @@ func testFileInfoSearchIgnoringStopWords(t *testing.T, th *SearchTestHelper) {
|
||||
params := &model.SearchParams{
|
||||
Terms: "in where you",
|
||||
}
|
||||
results, err := th.Store.FileInfo().Search([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
results, err := th.Store.FileInfo().Search(th.Context, []*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Len(t, results.FileInfos, 1)
|
||||
@@ -1111,14 +1113,14 @@ func testFileInfoSearchIgnoringStopWords(t *testing.T, th *SearchTestHelper) {
|
||||
})
|
||||
|
||||
t.Run("Should avoid stop words 'where', 'is' and 'the'", func(t *testing.T) {
|
||||
results, err := th.Store.FileInfo().Search([]*model.SearchParams{{Terms: "is the car"}}, th.User.Id, th.Team.Id, 0, 20)
|
||||
results, err := th.Store.FileInfo().Search(th.Context, []*model.SearchParams{{Terms: "is the car"}}, th.User.Id, th.Team.Id, 0, 20)
|
||||
require.NoError(t, err)
|
||||
require.Len(t, results.FileInfos, 1)
|
||||
th.checkFileInfoInSearchResults(t, p4.Id, results.FileInfos)
|
||||
})
|
||||
|
||||
t.Run("Should remove all terms and return empty list", func(t *testing.T) {
|
||||
results, err := th.Store.FileInfo().Search([]*model.SearchParams{{Terms: "is the"}}, th.User.Id, th.Team.Id, 0, 20)
|
||||
results, err := th.Store.FileInfo().Search(th.Context, []*model.SearchParams{{Terms: "is the"}}, th.User.Id, th.Team.Id, 0, 20)
|
||||
require.NoError(t, err)
|
||||
require.Empty(t, results.FileInfos)
|
||||
})
|
||||
@@ -1140,7 +1142,7 @@ func testFileInfoSupportStemming(t *testing.T, th *SearchTestHelper) {
|
||||
params := &model.SearchParams{
|
||||
Terms: "search",
|
||||
}
|
||||
results, err := th.Store.FileInfo().Search([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
results, err := th.Store.FileInfo().Search(th.Context, []*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Len(t, results.FileInfos, 2)
|
||||
@@ -1165,7 +1167,7 @@ func testFileInfoSupportWildcards(t *testing.T, th *SearchTestHelper) {
|
||||
params := &model.SearchParams{
|
||||
Terms: "search*",
|
||||
}
|
||||
results, err := th.Store.FileInfo().Search([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
results, err := th.Store.FileInfo().Search(th.Context, []*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Len(t, results.FileInfos, 2)
|
||||
@@ -1177,7 +1179,7 @@ func testFileInfoSupportWildcards(t *testing.T, th *SearchTestHelper) {
|
||||
params := &model.SearchParams{
|
||||
Terms: "sear* post",
|
||||
}
|
||||
results, err := th.Store.FileInfo().Search([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
results, err := th.Store.FileInfo().Search(th.Context, []*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Len(t, results.FileInfos, 1)
|
||||
@@ -1201,7 +1203,7 @@ func testFileInfoNotSupportPrecedingWildcards(t *testing.T, th *SearchTestHelper
|
||||
params := &model.SearchParams{
|
||||
Terms: "*earch",
|
||||
}
|
||||
results, err := th.Store.FileInfo().Search([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
results, err := th.Store.FileInfo().Search(th.Context, []*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Len(t, results.FileInfos, 0)
|
||||
@@ -1221,7 +1223,7 @@ func testFileInfoSearchDiscardWildcardAlone(t *testing.T, th *SearchTestHelper)
|
||||
params := &model.SearchParams{
|
||||
Terms: "qwerty *",
|
||||
}
|
||||
results, err := th.Store.FileInfo().Search([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
results, err := th.Store.FileInfo().Search(th.Context, []*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Len(t, results.FileInfos, 1)
|
||||
@@ -1243,7 +1245,7 @@ func testFileInfoSupportTermsWithDash(t *testing.T, th *SearchTestHelper) {
|
||||
params := &model.SearchParams{
|
||||
Terms: "term-with-dash",
|
||||
}
|
||||
results, err := th.Store.FileInfo().Search([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
results, err := th.Store.FileInfo().Search(th.Context, []*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Len(t, results.FileInfos, 1)
|
||||
@@ -1254,7 +1256,7 @@ func testFileInfoSupportTermsWithDash(t *testing.T, th *SearchTestHelper) {
|
||||
params := &model.SearchParams{
|
||||
Terms: "\"term-with-dash\"",
|
||||
}
|
||||
results, err := th.Store.FileInfo().Search([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
results, err := th.Store.FileInfo().Search(th.Context, []*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Len(t, results.FileInfos, 1)
|
||||
@@ -1277,7 +1279,7 @@ func testFileInfoSupportTermsWithUnderscore(t *testing.T, th *SearchTestHelper)
|
||||
params := &model.SearchParams{
|
||||
Terms: "term_with_underscore",
|
||||
}
|
||||
results, err := th.Store.FileInfo().Search([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
results, err := th.Store.FileInfo().Search(th.Context, []*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Len(t, results.FileInfos, 1)
|
||||
@@ -1288,7 +1290,7 @@ func testFileInfoSupportTermsWithUnderscore(t *testing.T, th *SearchTestHelper)
|
||||
params := &model.SearchParams{
|
||||
Terms: "\"term_with_underscore\"",
|
||||
}
|
||||
results, err := th.Store.FileInfo().Search([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
results, err := th.Store.FileInfo().Search(th.Context, []*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Len(t, results.FileInfos, 1)
|
||||
@@ -1317,7 +1319,7 @@ func testFileInfoSearchInDeletedOrArchivedChannels(t *testing.T, th *SearchTestH
|
||||
|
||||
t.Run("Doesn't include posts in deleted channels", func(t *testing.T) {
|
||||
params := &model.SearchParams{Terms: "message", IncludeDeletedChannels: false}
|
||||
results, err := th.Store.FileInfo().Search([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
results, err := th.Store.FileInfo().Search(th.Context, []*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Len(t, results.FileInfos, 2)
|
||||
@@ -1327,7 +1329,7 @@ func testFileInfoSearchInDeletedOrArchivedChannels(t *testing.T, th *SearchTestH
|
||||
|
||||
t.Run("Include posts in deleted channels", func(t *testing.T) {
|
||||
params := &model.SearchParams{Terms: "message", IncludeDeletedChannels: true}
|
||||
results, err := th.Store.FileInfo().Search([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
results, err := th.Store.FileInfo().Search(th.Context, []*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Len(t, results.FileInfos, 3)
|
||||
@@ -1338,7 +1340,7 @@ func testFileInfoSearchInDeletedOrArchivedChannels(t *testing.T, th *SearchTestH
|
||||
|
||||
t.Run("Include posts in deleted channels using multiple terms", func(t *testing.T) {
|
||||
params := &model.SearchParams{Terms: "message channel", IncludeDeletedChannels: true}
|
||||
results, err := th.Store.FileInfo().Search([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
results, err := th.Store.FileInfo().Search(th.Context, []*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Len(t, results.FileInfos, 3)
|
||||
@@ -1353,7 +1355,7 @@ func testFileInfoSearchInDeletedOrArchivedChannels(t *testing.T, th *SearchTestH
|
||||
IncludeDeletedChannels: true,
|
||||
OrTerms: true,
|
||||
}
|
||||
results, err := th.Store.FileInfo().Search([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
results, err := th.Store.FileInfo().Search(th.Context, []*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Len(t, results.FileInfos, 3)
|
||||
@@ -1371,7 +1373,7 @@ func testFileInfoSearchInDeletedOrArchivedChannels(t *testing.T, th *SearchTestH
|
||||
Terms: "#hashtag",
|
||||
IncludeDeletedChannels: false,
|
||||
}
|
||||
results, err := th.Store.FileInfo().Search([]*model.SearchParams{params1, params2}, th.User.Id, th.Team.Id, 0, 20)
|
||||
results, err := th.Store.FileInfo().Search(th.Context, []*model.SearchParams{params1, params2}, th.User.Id, th.Team.Id, 0, 20)
|
||||
require.Nil(t, results)
|
||||
require.Error(t, err)
|
||||
})
|
||||
@@ -1390,7 +1392,7 @@ func testFileInfoSearchTermsWithDashes(t *testing.T, th *SearchTestHelper) {
|
||||
|
||||
t.Run("Search for terms with dash", func(t *testing.T) {
|
||||
params := &model.SearchParams{Terms: "with-dash-term"}
|
||||
results, err := th.Store.FileInfo().Search([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
results, err := th.Store.FileInfo().Search(th.Context, []*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Len(t, results.FileInfos, 1)
|
||||
@@ -1399,7 +1401,7 @@ func testFileInfoSearchTermsWithDashes(t *testing.T, th *SearchTestHelper) {
|
||||
|
||||
t.Run("Search for terms with quoted dash", func(t *testing.T) {
|
||||
params := &model.SearchParams{Terms: "\"with-dash-term\""}
|
||||
results, err := th.Store.FileInfo().Search([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
results, err := th.Store.FileInfo().Search(th.Context, []*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Len(t, results.FileInfos, 1)
|
||||
@@ -1408,7 +1410,7 @@ func testFileInfoSearchTermsWithDashes(t *testing.T, th *SearchTestHelper) {
|
||||
|
||||
t.Run("Search for multiple terms with one having dash", func(t *testing.T) {
|
||||
params := &model.SearchParams{Terms: "with-dash-term message"}
|
||||
results, err := th.Store.FileInfo().Search([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
results, err := th.Store.FileInfo().Search(th.Context, []*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Len(t, results.FileInfos, 1)
|
||||
@@ -1417,7 +1419,7 @@ func testFileInfoSearchTermsWithDashes(t *testing.T, th *SearchTestHelper) {
|
||||
|
||||
t.Run("Search for multiple OR terms with one having dash", func(t *testing.T) {
|
||||
params := &model.SearchParams{Terms: "with-dash-term message", OrTerms: true}
|
||||
results, err := th.Store.FileInfo().Search([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
results, err := th.Store.FileInfo().Search(th.Context, []*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Len(t, results.FileInfos, 2)
|
||||
@@ -1439,7 +1441,7 @@ func testFileInfoSearchTermsWithDots(t *testing.T, th *SearchTestHelper) {
|
||||
|
||||
t.Run("Search for terms with dots", func(t *testing.T) {
|
||||
params := &model.SearchParams{Terms: "with.dots.term"}
|
||||
results, err := th.Store.FileInfo().Search([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
results, err := th.Store.FileInfo().Search(th.Context, []*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Len(t, results.FileInfos, 1)
|
||||
@@ -1448,7 +1450,7 @@ func testFileInfoSearchTermsWithDots(t *testing.T, th *SearchTestHelper) {
|
||||
|
||||
t.Run("Search for terms with quoted dots", func(t *testing.T) {
|
||||
params := &model.SearchParams{Terms: "\"with.dots.term\""}
|
||||
results, err := th.Store.FileInfo().Search([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
results, err := th.Store.FileInfo().Search(th.Context, []*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Len(t, results.FileInfos, 1)
|
||||
@@ -1457,7 +1459,7 @@ func testFileInfoSearchTermsWithDots(t *testing.T, th *SearchTestHelper) {
|
||||
|
||||
t.Run("Search for multiple terms with one having dots", func(t *testing.T) {
|
||||
params := &model.SearchParams{Terms: "with.dots.term message"}
|
||||
results, err := th.Store.FileInfo().Search([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
results, err := th.Store.FileInfo().Search(th.Context, []*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Len(t, results.FileInfos, 1)
|
||||
@@ -1466,7 +1468,7 @@ func testFileInfoSearchTermsWithDots(t *testing.T, th *SearchTestHelper) {
|
||||
|
||||
t.Run("Search for multiple OR terms with one having dots", func(t *testing.T) {
|
||||
params := &model.SearchParams{Terms: "with.dots.term message", OrTerms: true}
|
||||
results, err := th.Store.FileInfo().Search([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
results, err := th.Store.FileInfo().Search(th.Context, []*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Len(t, results.FileInfos, 2)
|
||||
@@ -1488,7 +1490,7 @@ func testFileInfoSearchTermsWithUnderscores(t *testing.T, th *SearchTestHelper)
|
||||
|
||||
t.Run("Search for terms with underscores", func(t *testing.T) {
|
||||
params := &model.SearchParams{Terms: "with_underscores_term"}
|
||||
results, err := th.Store.FileInfo().Search([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
results, err := th.Store.FileInfo().Search(th.Context, []*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Len(t, results.FileInfos, 1)
|
||||
@@ -1497,7 +1499,7 @@ func testFileInfoSearchTermsWithUnderscores(t *testing.T, th *SearchTestHelper)
|
||||
|
||||
t.Run("Search for terms with quoted underscores", func(t *testing.T) {
|
||||
params := &model.SearchParams{Terms: "\"with_underscores_term\""}
|
||||
results, err := th.Store.FileInfo().Search([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
results, err := th.Store.FileInfo().Search(th.Context, []*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Len(t, results.FileInfos, 1)
|
||||
@@ -1506,7 +1508,7 @@ func testFileInfoSearchTermsWithUnderscores(t *testing.T, th *SearchTestHelper)
|
||||
|
||||
t.Run("Search for multiple terms with one having underscores", func(t *testing.T) {
|
||||
params := &model.SearchParams{Terms: "with_underscores_term message"}
|
||||
results, err := th.Store.FileInfo().Search([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
results, err := th.Store.FileInfo().Search(th.Context, []*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Len(t, results.FileInfos, 1)
|
||||
@@ -1515,7 +1517,7 @@ func testFileInfoSearchTermsWithUnderscores(t *testing.T, th *SearchTestHelper)
|
||||
|
||||
t.Run("Search for multiple OR terms with one having underscores", func(t *testing.T) {
|
||||
params := &model.SearchParams{Terms: "with_underscores_term message", OrTerms: true}
|
||||
results, err := th.Store.FileInfo().Search([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
results, err := th.Store.FileInfo().Search(th.Context, []*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Len(t, results.FileInfos, 2)
|
||||
@@ -1542,7 +1544,7 @@ func testFileInfoSupportStemmingAndWildcards(t *testing.T, th *SearchTestHelper)
|
||||
|
||||
t.Run("Should stem appr", func(t *testing.T) {
|
||||
params := &model.SearchParams{Terms: "appr*"}
|
||||
results, err := th.Store.FileInfo().Search([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
results, err := th.Store.FileInfo().Search(th.Context, []*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Len(t, results.FileInfos, 3)
|
||||
@@ -1553,7 +1555,7 @@ func testFileInfoSupportStemmingAndWildcards(t *testing.T, th *SearchTestHelper)
|
||||
|
||||
t.Run("Should stem approve", func(t *testing.T) {
|
||||
params := &model.SearchParams{Terms: "approve*"}
|
||||
results, err := th.Store.FileInfo().Search([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
results, err := th.Store.FileInfo().Search(th.Context, []*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Len(t, results.FileInfos, 1)
|
||||
@@ -1576,7 +1578,7 @@ func testFileInfoSupportWildcardOutsideQuotes(t *testing.T, th *SearchTestHelper
|
||||
|
||||
t.Run("Should return results without quotes", func(t *testing.T) {
|
||||
params := &model.SearchParams{Terms: "hell*"}
|
||||
results, err := th.Store.FileInfo().Search([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
results, err := th.Store.FileInfo().Search(th.Context, []*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Len(t, results.FileInfos, 2)
|
||||
@@ -1586,7 +1588,7 @@ func testFileInfoSupportWildcardOutsideQuotes(t *testing.T, th *SearchTestHelper
|
||||
|
||||
t.Run("Should return just one result with quotes", func(t *testing.T) {
|
||||
params := &model.SearchParams{Terms: "\"hell\"*"}
|
||||
results, err := th.Store.FileInfo().Search([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
results, err := th.Store.FileInfo().Search(th.Context, []*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Len(t, results.FileInfos, 1)
|
||||
@@ -1604,21 +1606,21 @@ func testFileInfoSlashShouldNotBeCharSeparator(t *testing.T, th *SearchTestHelpe
|
||||
defer th.deleteUserFileInfos(th.User.Id)
|
||||
|
||||
params := &model.SearchParams{Terms: "gamma"}
|
||||
results, err := th.Store.FileInfo().Search([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
results, err := th.Store.FileInfo().Search(th.Context, []*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Len(t, results.FileInfos, 1)
|
||||
th.checkFileInfoInSearchResults(t, p1.Id, results.FileInfos)
|
||||
|
||||
params = &model.SearchParams{Terms: "beta"}
|
||||
results, err = th.Store.FileInfo().Search([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
results, err = th.Store.FileInfo().Search(th.Context, []*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Len(t, results.FileInfos, 1)
|
||||
th.checkFileInfoInSearchResults(t, p1.Id, results.FileInfos)
|
||||
|
||||
params = &model.SearchParams{Terms: "alpha"}
|
||||
results, err = th.Store.FileInfo().Search([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
results, err = th.Store.FileInfo().Search(th.Context, []*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Len(t, results.FileInfos, 1)
|
||||
@@ -1637,7 +1639,7 @@ func testFileInfoSearchEmailsWithoutQuotes(t *testing.T, th *SearchTestHelper) {
|
||||
defer th.deleteUserFileInfos(th.User.Id)
|
||||
|
||||
params := &model.SearchParams{Terms: "test@test.com"}
|
||||
results, err := th.Store.FileInfo().Search([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
results, err := th.Store.FileInfo().Search(th.Context, []*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Len(t, results.FileInfos, 1)
|
||||
|
||||
Ссылка в новой задаче
Block a user