|
|
|
|
@@ -96,7 +96,7 @@ var searchPostStoreTests = []searchTest{
|
|
|
|
|
{
|
|
|
|
|
Name: "Should be able to search using boolean operators",
|
|
|
|
|
Fn: testSearchUsingBooleanOperators,
|
|
|
|
|
Tags: []string{ENGINE_ELASTICSEARCH},
|
|
|
|
|
Tags: []string{ENGINE_MYSQL, ENGINE_POSTGRES, ENGINE_ELASTICSEARCH},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
Name: "Should be able to search with combined filters",
|
|
|
|
|
@@ -195,11 +195,9 @@ var searchPostStoreTests = []searchTest{
|
|
|
|
|
Tags: []string{ENGINE_ALL},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
Name: "Should be able to search in deleted/archived channels",
|
|
|
|
|
Fn: testSearchInDeletedOrArchivedChannels,
|
|
|
|
|
Tags: []string{ENGINE_ALL},
|
|
|
|
|
Skip: true,
|
|
|
|
|
SkipMessage: "Not working",
|
|
|
|
|
Name: "Should be able to search in deleted/archived channels",
|
|
|
|
|
Fn: testSearchInDeletedOrArchivedChannels,
|
|
|
|
|
Tags: []string{ENGINE_MYSQL, ENGINE_POSTGRES},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
Name: "Should be able to search terms with dashes",
|
|
|
|
|
@@ -211,12 +209,12 @@ var searchPostStoreTests = []searchTest{
|
|
|
|
|
{
|
|
|
|
|
Name: "Should be able to search terms with dots",
|
|
|
|
|
Fn: testSearchTermsWithDots,
|
|
|
|
|
Tags: []string{ENGINE_ELASTICSEARCH},
|
|
|
|
|
Tags: []string{ENGINE_POSTGRES, ENGINE_ELASTICSEARCH},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
Name: "Should be able to search terms with underscores",
|
|
|
|
|
Fn: testSearchTermsWithUnderscores,
|
|
|
|
|
Tags: []string{ENGINE_ELASTICSEARCH},
|
|
|
|
|
Tags: []string{ENGINE_MYSQL, ENGINE_ELASTICSEARCH},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
Name: "Should be able to search posts made by bot accounts",
|
|
|
|
|
@@ -290,7 +288,7 @@ func testSearchPostsIncludingDMs(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
defer th.deleteUserPosts(th.User.Id)
|
|
|
|
|
|
|
|
|
|
params := &model.SearchParams{Terms: "test"}
|
|
|
|
|
results, err := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20)
|
|
|
|
|
results, err := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.Nil(t, err)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 2)
|
|
|
|
|
@@ -312,13 +310,13 @@ func testSearchPostsWithPagination(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
defer th.deleteUserPosts(th.User.Id)
|
|
|
|
|
|
|
|
|
|
params := &model.SearchParams{Terms: "test"}
|
|
|
|
|
results, err := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 1)
|
|
|
|
|
results, err := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 1)
|
|
|
|
|
require.Nil(t, err)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
th.checkPostInSearchResults(t, p2.Id, results.Posts)
|
|
|
|
|
|
|
|
|
|
results, err = th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 1, 1)
|
|
|
|
|
results, err = th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 1, 1)
|
|
|
|
|
require.Nil(t, err)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
@@ -333,7 +331,7 @@ func testSearchReturnPinnedAndUnpinned(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
defer th.deleteUserPosts(th.User.Id)
|
|
|
|
|
|
|
|
|
|
params := &model.SearchParams{Terms: "test"}
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20)
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.Nil(t, apperr)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 2)
|
|
|
|
|
@@ -349,7 +347,7 @@ func testSearchExactPhraseInQuotes(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
defer th.deleteUserPosts(th.User.Id)
|
|
|
|
|
|
|
|
|
|
params := &model.SearchParams{Terms: "\"channel test 1 2 3\""}
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20)
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.Nil(t, apperr)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
@@ -365,7 +363,7 @@ func testSearchEmailAddresses(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
|
|
|
|
|
t.Run("Should search email addresses enclosed by quotes", func(t *testing.T) {
|
|
|
|
|
params := &model.SearchParams{Terms: "\"test@test.com\""}
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20)
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.Nil(t, apperr)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
@@ -374,7 +372,7 @@ func testSearchEmailAddresses(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, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20)
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.Nil(t, apperr)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
@@ -389,7 +387,7 @@ func testSearchMarkdownUnderscores(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, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20)
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.Nil(t, apperr)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
@@ -398,7 +396,7 @@ func testSearchMarkdownUnderscores(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, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20)
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.Nil(t, apperr)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
@@ -407,7 +405,7 @@ func testSearchMarkdownUnderscores(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, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20)
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.Nil(t, apperr)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
@@ -416,7 +414,7 @@ func testSearchMarkdownUnderscores(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
|
|
|
|
|
t.Run("Should search inside markdown underscore", func(t *testing.T) {
|
|
|
|
|
params := &model.SearchParams{Terms: "another"}
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20)
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.Nil(t, apperr)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
@@ -434,7 +432,7 @@ func testSearchNonLatinWords(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
|
|
|
|
|
t.Run("Should search one word", func(t *testing.T) {
|
|
|
|
|
params := &model.SearchParams{Terms: "你"}
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20)
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.Nil(t, apperr)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
@@ -442,7 +440,7 @@ func testSearchNonLatinWords(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
})
|
|
|
|
|
t.Run("Should search two words", func(t *testing.T) {
|
|
|
|
|
params := &model.SearchParams{Terms: "你好"}
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20)
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.Nil(t, apperr)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
@@ -450,7 +448,7 @@ func testSearchNonLatinWords(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
})
|
|
|
|
|
t.Run("Should search with wildcard", func(t *testing.T) {
|
|
|
|
|
params := &model.SearchParams{Terms: "你*"}
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20)
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.Nil(t, apperr)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 2)
|
|
|
|
|
@@ -465,7 +463,7 @@ func testSearchNonLatinWords(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
|
|
|
|
|
t.Run("Should search one word", func(t *testing.T) {
|
|
|
|
|
params := &model.SearchParams{Terms: "слово"}
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20)
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.Nil(t, apperr)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
@@ -473,7 +471,7 @@ func testSearchNonLatinWords(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
})
|
|
|
|
|
t.Run("Should search using wildcard", func(t *testing.T) {
|
|
|
|
|
params := &model.SearchParams{Terms: "слов*"}
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20)
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.Nil(t, apperr)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
@@ -490,7 +488,7 @@ func testSearchNonLatinWords(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
|
|
|
|
|
t.Run("Should search one word", func(t *testing.T) {
|
|
|
|
|
params := &model.SearchParams{Terms: "本"}
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20)
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.Nil(t, apperr)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 2)
|
|
|
|
|
@@ -499,7 +497,7 @@ func testSearchNonLatinWords(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
})
|
|
|
|
|
t.Run("Should search two words", func(t *testing.T) {
|
|
|
|
|
params := &model.SearchParams{Terms: "本木"}
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20)
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.Nil(t, apperr)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
@@ -507,7 +505,7 @@ func testSearchNonLatinWords(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
})
|
|
|
|
|
t.Run("Should search with wildcard", func(t *testing.T) {
|
|
|
|
|
params := &model.SearchParams{Terms: "本*"}
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20)
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.Nil(t, apperr)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 2)
|
|
|
|
|
@@ -525,7 +523,7 @@ func testSearchNonLatinWords(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
|
|
|
|
|
t.Run("Should search one word", func(t *testing.T) {
|
|
|
|
|
params := &model.SearchParams{Terms: "불"}
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20)
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.Nil(t, apperr)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
@@ -533,7 +531,7 @@ func testSearchNonLatinWords(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
})
|
|
|
|
|
t.Run("Should search two words", func(t *testing.T) {
|
|
|
|
|
params := &model.SearchParams{Terms: "불다"}
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20)
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.Nil(t, apperr)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
@@ -541,7 +539,7 @@ func testSearchNonLatinWords(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
})
|
|
|
|
|
t.Run("Should search with wildcard", func(t *testing.T) {
|
|
|
|
|
params := &model.SearchParams{Terms: "불*"}
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20)
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.Nil(t, apperr)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 2)
|
|
|
|
|
@@ -559,7 +557,7 @@ func testSearchAlternativeSpellings(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
defer th.deleteUserPosts(th.User.Id)
|
|
|
|
|
|
|
|
|
|
params := &model.SearchParams{Terms: "Straße"}
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20)
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.Nil(t, apperr)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 2)
|
|
|
|
|
@@ -567,7 +565,7 @@ func testSearchAlternativeSpellings(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
th.checkPostInSearchResults(t, p2.Id, results.Posts)
|
|
|
|
|
|
|
|
|
|
params = &model.SearchParams{Terms: "Strasse"}
|
|
|
|
|
results, apperr = th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20)
|
|
|
|
|
results, apperr = th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.Nil(t, apperr)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 2)
|
|
|
|
|
@@ -583,7 +581,7 @@ func testSearchAlternativeSpellingsAccents(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
defer th.deleteUserPosts(th.User.Id)
|
|
|
|
|
|
|
|
|
|
params := &model.SearchParams{Terms: "café"}
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20)
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.Nil(t, apperr)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 2)
|
|
|
|
|
@@ -591,7 +589,7 @@ func testSearchAlternativeSpellingsAccents(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
th.checkPostInSearchResults(t, p2.Id, results.Posts)
|
|
|
|
|
|
|
|
|
|
params = &model.SearchParams{Terms: "café"}
|
|
|
|
|
results, apperr = th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20)
|
|
|
|
|
results, apperr = th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.Nil(t, apperr)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 2)
|
|
|
|
|
@@ -599,7 +597,7 @@ func testSearchAlternativeSpellingsAccents(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
th.checkPostInSearchResults(t, p2.Id, results.Posts)
|
|
|
|
|
|
|
|
|
|
params = &model.SearchParams{Terms: "cafe"}
|
|
|
|
|
results, apperr = th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20)
|
|
|
|
|
results, apperr = th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.Nil(t, apperr)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 0)
|
|
|
|
|
@@ -617,7 +615,7 @@ func testSearchOrExcludePostsBySpecificUser(t *testing.T, th *SearchTestHelper)
|
|
|
|
|
Terms: "fromuser",
|
|
|
|
|
FromUsers: []string{th.User.Id},
|
|
|
|
|
}
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20)
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.Nil(t, apperr)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
@@ -636,7 +634,7 @@ func testSearchOrExcludePostsInChannel(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
Terms: "fromuser",
|
|
|
|
|
InChannels: []string{th.ChannelBasic.Id},
|
|
|
|
|
}
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20)
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.Nil(t, apperr)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
@@ -664,7 +662,7 @@ func testSearchOrExcludePostsInDMGM(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
Terms: "fromuser",
|
|
|
|
|
InChannels: []string{direct.Id, group.Id},
|
|
|
|
|
}
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20)
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.Nil(t, apperr)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 2)
|
|
|
|
|
@@ -677,7 +675,7 @@ func testSearchOrExcludePostsInDMGM(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
Terms: "fromuser",
|
|
|
|
|
InChannels: []string{direct.Id},
|
|
|
|
|
}
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20)
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.Nil(t, apperr)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
@@ -689,7 +687,7 @@ func testSearchOrExcludePostsInDMGM(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
Terms: "fromuser",
|
|
|
|
|
InChannels: []string{group.Id},
|
|
|
|
|
}
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20)
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.Nil(t, apperr)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
@@ -714,7 +712,7 @@ func testFilterMessagesInSpecificDate(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
Terms: "test",
|
|
|
|
|
OnDate: "2020-03-22",
|
|
|
|
|
}
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20)
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.Nil(t, apperr)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
@@ -725,7 +723,7 @@ func testFilterMessagesInSpecificDate(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
Terms: "test",
|
|
|
|
|
ExcludedDate: "2020-03-22",
|
|
|
|
|
}
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20)
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.Nil(t, apperr)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 2)
|
|
|
|
|
@@ -751,7 +749,7 @@ func testFilterMessagesBeforeSpecificDate(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
Terms: "test",
|
|
|
|
|
BeforeDate: "2020-03-23",
|
|
|
|
|
}
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20)
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.Nil(t, apperr)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 2)
|
|
|
|
|
@@ -764,7 +762,7 @@ func testFilterMessagesBeforeSpecificDate(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
Terms: "test",
|
|
|
|
|
ExcludedBeforeDate: "2020-03-23",
|
|
|
|
|
}
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20)
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.Nil(t, apperr)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
@@ -789,7 +787,7 @@ func testFilterMessagesAfterSpecificDate(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
Terms: "test",
|
|
|
|
|
AfterDate: "2020-03-23",
|
|
|
|
|
}
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20)
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.Nil(t, apperr)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
@@ -801,7 +799,7 @@ func testFilterMessagesAfterSpecificDate(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
Terms: "test",
|
|
|
|
|
ExcludedAfterDate: "2020-03-23",
|
|
|
|
|
}
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20)
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.Nil(t, apperr)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 2)
|
|
|
|
|
@@ -824,7 +822,7 @@ func testFilterMessagesWithATerm(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
Terms: "one",
|
|
|
|
|
ExcludedTerms: "five eight",
|
|
|
|
|
}
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20)
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.Nil(t, apperr)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
@@ -836,7 +834,7 @@ func testFilterMessagesWithATerm(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
Terms: "one",
|
|
|
|
|
ExcludedTerms: "\"eight nine\"",
|
|
|
|
|
}
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20)
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.Nil(t, apperr)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 2)
|
|
|
|
|
@@ -859,7 +857,7 @@ func testSearchUsingBooleanOperators(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
Terms: "one two",
|
|
|
|
|
OrTerms: true,
|
|
|
|
|
}
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20)
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.Nil(t, apperr)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 2)
|
|
|
|
|
@@ -872,7 +870,7 @@ func testSearchUsingBooleanOperators(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
Terms: "one two",
|
|
|
|
|
OrTerms: false,
|
|
|
|
|
}
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20)
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.Nil(t, apperr)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
@@ -899,7 +897,7 @@ func testSearchUsingCombinedFilters(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
FromUsers: []string{th.User2.Id},
|
|
|
|
|
InChannels: []string{th.ChannelPrivate.Id},
|
|
|
|
|
}
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20)
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.Nil(t, apperr)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
@@ -912,7 +910,7 @@ func testSearchUsingCombinedFilters(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
ExcludedUsers: []string{th.User2.Id},
|
|
|
|
|
InChannels: []string{th.ChannelPrivate.Id},
|
|
|
|
|
}
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20)
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.Nil(t, apperr)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
@@ -926,7 +924,7 @@ func testSearchUsingCombinedFilters(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
ExcludedAfterDate: "2020-03-11",
|
|
|
|
|
InChannels: []string{th.ChannelPrivate.Id},
|
|
|
|
|
}
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20)
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.Nil(t, apperr)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
@@ -938,7 +936,7 @@ func testSearchUsingCombinedFilters(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
AfterDate: "2020-03-11",
|
|
|
|
|
ExcludedChannels: []string{th.ChannelPrivate.Id},
|
|
|
|
|
}
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20)
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.Nil(t, apperr)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
@@ -961,7 +959,7 @@ func testSearchIgnoringStopWords(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
params := &model.SearchParams{
|
|
|
|
|
Terms: "the search",
|
|
|
|
|
}
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20)
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.Nil(t, apperr)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
@@ -972,7 +970,7 @@ func testSearchIgnoringStopWords(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
params := &model.SearchParams{
|
|
|
|
|
Terms: "a avoid",
|
|
|
|
|
}
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20)
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.Nil(t, apperr)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
@@ -983,7 +981,7 @@ func testSearchIgnoringStopWords(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
params := &model.SearchParams{
|
|
|
|
|
Terms: "in where you",
|
|
|
|
|
}
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20)
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.Nil(t, apperr)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
@@ -1016,7 +1014,7 @@ func testSupportStemming(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
params := &model.SearchParams{
|
|
|
|
|
Terms: "search",
|
|
|
|
|
}
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20)
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.Nil(t, apperr)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 2)
|
|
|
|
|
@@ -1036,7 +1034,7 @@ func testSupportWildcards(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
params := &model.SearchParams{
|
|
|
|
|
Terms: "search*",
|
|
|
|
|
}
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20)
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.Nil(t, apperr)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 2)
|
|
|
|
|
@@ -1056,7 +1054,7 @@ func testNotSupportPrecedingWildcards(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
params := &model.SearchParams{
|
|
|
|
|
Terms: "*earch",
|
|
|
|
|
}
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20)
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.Nil(t, apperr)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 0)
|
|
|
|
|
@@ -1072,7 +1070,7 @@ func testSearchDiscardWildcardAlone(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
params := &model.SearchParams{
|
|
|
|
|
Terms: "qwerty *",
|
|
|
|
|
}
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20)
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.Nil(t, apperr)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
@@ -1090,7 +1088,7 @@ func testSupportTermsWithDash(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
params := &model.SearchParams{
|
|
|
|
|
Terms: "term-with-dash",
|
|
|
|
|
}
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20)
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.Nil(t, apperr)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
@@ -1101,7 +1099,7 @@ func testSupportTermsWithDash(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
params := &model.SearchParams{
|
|
|
|
|
Terms: "\"term-with-dash\"",
|
|
|
|
|
}
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20)
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.Nil(t, apperr)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
@@ -1120,7 +1118,7 @@ func testSupportTermsWithUnderscore(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
params := &model.SearchParams{
|
|
|
|
|
Terms: "term_with_underscore",
|
|
|
|
|
}
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20)
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.Nil(t, apperr)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
@@ -1131,7 +1129,7 @@ func testSupportTermsWithUnderscore(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
params := &model.SearchParams{
|
|
|
|
|
Terms: "\"term_with_underscore\"",
|
|
|
|
|
}
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20)
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.Nil(t, apperr)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
@@ -1153,7 +1151,7 @@ func testSearchOrExcludePostsWithHashtags(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
Terms: "#hashtag",
|
|
|
|
|
IsHashtag: true,
|
|
|
|
|
}
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20)
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.Nil(t, apperr)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 2)
|
|
|
|
|
@@ -1166,7 +1164,7 @@ func testSearchOrExcludePostsWithHashtags(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
Terms: "#hashtag",
|
|
|
|
|
IsHashtag: false,
|
|
|
|
|
}
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20)
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.Nil(t, apperr)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 2)
|
|
|
|
|
@@ -1192,7 +1190,7 @@ func testSearchHashtagWithMarkdown(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
Terms: "#hashtag",
|
|
|
|
|
IsHashtag: true,
|
|
|
|
|
}
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20)
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.Nil(t, apperr)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 5)
|
|
|
|
|
@@ -1215,7 +1213,7 @@ func testSearcWithMultipleHashtags(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
Terms: "#hashone #hashtwo",
|
|
|
|
|
IsHashtag: true,
|
|
|
|
|
}
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20)
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.Nil(t, apperr)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
@@ -1228,7 +1226,7 @@ func testSearcWithMultipleHashtags(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
IsHashtag: true,
|
|
|
|
|
OrTerms: true,
|
|
|
|
|
}
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20)
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.Nil(t, apperr)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 2)
|
|
|
|
|
@@ -1246,7 +1244,7 @@ func testSearchPostsWithDotsInHashtags(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
Terms: "#hashtag.dot",
|
|
|
|
|
IsHashtag: true,
|
|
|
|
|
}
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20)
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.Nil(t, apperr)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
@@ -1267,7 +1265,7 @@ func testSearchHashtagCaseInsensitive(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
Terms: "#hashtag",
|
|
|
|
|
IsHashtag: true,
|
|
|
|
|
}
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20)
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.Nil(t, apperr)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 3)
|
|
|
|
|
@@ -1281,7 +1279,7 @@ func testSearchHashtagCaseInsensitive(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
Terms: "#HASHTAG",
|
|
|
|
|
IsHashtag: true,
|
|
|
|
|
}
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20)
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.Nil(t, apperr)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 3)
|
|
|
|
|
@@ -1295,7 +1293,7 @@ func testSearchHashtagCaseInsensitive(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
Terms: "#HaShTaG",
|
|
|
|
|
IsHashtag: true,
|
|
|
|
|
}
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20)
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.Nil(t, apperr)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 3)
|
|
|
|
|
@@ -1316,7 +1314,7 @@ func testSearchHashtagWithDash(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
Terms: "#hashtag-test",
|
|
|
|
|
IsHashtag: true,
|
|
|
|
|
}
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20)
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.Nil(t, apperr)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
@@ -1334,7 +1332,7 @@ func testSearchHashtagWithNumbers(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
Terms: "#h4sht4g",
|
|
|
|
|
IsHashtag: true,
|
|
|
|
|
}
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20)
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.Nil(t, apperr)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
@@ -1352,7 +1350,7 @@ func testSearchHashtagWithDots(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
Terms: "#hashtag.test",
|
|
|
|
|
IsHashtag: true,
|
|
|
|
|
}
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20)
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.Nil(t, apperr)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
@@ -1370,7 +1368,7 @@ func testSearchHashtagWithUnderscores(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
Terms: "#hashtag_test",
|
|
|
|
|
IsHashtag: true,
|
|
|
|
|
}
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20)
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.Nil(t, apperr)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
@@ -1393,7 +1391,7 @@ func testSearchShouldExcludeSytemMessages(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
defer th.deleteUserPosts(th.User.Id)
|
|
|
|
|
|
|
|
|
|
params := &model.SearchParams{Terms: "test system"}
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20)
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.Nil(t, apperr)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 0)
|
|
|
|
|
@@ -1409,7 +1407,7 @@ func testSearchShouldBeAbleToMatchByMentions(t *testing.T, th *SearchTestHelper)
|
|
|
|
|
defer th.deleteUserPosts(th.User.Id)
|
|
|
|
|
|
|
|
|
|
params := &model.SearchParams{Terms: "@testuser"}
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20)
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.Nil(t, apperr)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 3)
|
|
|
|
|
@@ -1429,7 +1427,7 @@ func testSearchInDeletedOrArchivedChannels(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
|
|
|
|
|
t.Run("Doesn't include posts in deleted channels", func(t *testing.T) {
|
|
|
|
|
params := &model.SearchParams{Terms: "message", IncludeDeletedChannels: false}
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20)
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.Nil(t, apperr)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 2)
|
|
|
|
|
@@ -1439,7 +1437,7 @@ func testSearchInDeletedOrArchivedChannels(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
|
|
|
|
|
t.Run("Include posts in deleted channels", func(t *testing.T) {
|
|
|
|
|
params := &model.SearchParams{Terms: "message", IncludeDeletedChannels: true}
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20)
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.Nil(t, apperr)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 3)
|
|
|
|
|
@@ -1450,7 +1448,7 @@ func testSearchInDeletedOrArchivedChannels(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
|
|
|
|
|
t.Run("Include posts in deleted channels using multiple terms", func(t *testing.T) {
|
|
|
|
|
params := &model.SearchParams{Terms: "message channel", IncludeDeletedChannels: true}
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20)
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.Nil(t, apperr)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 3)
|
|
|
|
|
@@ -1465,7 +1463,7 @@ func testSearchInDeletedOrArchivedChannels(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
IncludeDeletedChannels: true,
|
|
|
|
|
OrTerms: true,
|
|
|
|
|
}
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20)
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.Nil(t, apperr)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 3)
|
|
|
|
|
@@ -1473,6 +1471,20 @@ func testSearchInDeletedOrArchivedChannels(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
th.checkPostInSearchResults(t, p2.Id, results.Posts)
|
|
|
|
|
th.checkPostInSearchResults(t, p3.Id, results.Posts)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
t.Run("All IncludeDeletedChannels params should have same value if multiple SearchParams provided", func(t *testing.T) {
|
|
|
|
|
params1 := &model.SearchParams{
|
|
|
|
|
Terms: "message channel",
|
|
|
|
|
IncludeDeletedChannels: true,
|
|
|
|
|
}
|
|
|
|
|
params2 := &model.SearchParams{
|
|
|
|
|
Terms: "#hashtag",
|
|
|
|
|
IncludeDeletedChannels: false,
|
|
|
|
|
}
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params1, params2}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.Nil(t, results)
|
|
|
|
|
require.NotNil(t, apperr)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func testSearchTermsWithDashes(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
@@ -1484,7 +1496,7 @@ func testSearchTermsWithDashes(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
|
|
|
|
|
t.Run("Search for terms with dash", func(t *testing.T) {
|
|
|
|
|
params := &model.SearchParams{Terms: "with-dash-term"}
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20)
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.Nil(t, apperr)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
@@ -1493,7 +1505,7 @@ func testSearchTermsWithDashes(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, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20)
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.Nil(t, apperr)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
@@ -1502,7 +1514,7 @@ func testSearchTermsWithDashes(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, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20)
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.Nil(t, apperr)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
@@ -1511,7 +1523,7 @@ func testSearchTermsWithDashes(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, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20)
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.Nil(t, apperr)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 2)
|
|
|
|
|
@@ -1529,7 +1541,7 @@ func testSearchTermsWithDots(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
|
|
|
|
|
t.Run("Search for terms with dots", func(t *testing.T) {
|
|
|
|
|
params := &model.SearchParams{Terms: "with.dots.term"}
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20)
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.Nil(t, apperr)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
@@ -1538,7 +1550,7 @@ func testSearchTermsWithDots(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, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20)
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.Nil(t, apperr)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
@@ -1547,7 +1559,7 @@ func testSearchTermsWithDots(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, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20)
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.Nil(t, apperr)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
@@ -1556,7 +1568,7 @@ func testSearchTermsWithDots(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, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20)
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.Nil(t, apperr)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 2)
|
|
|
|
|
@@ -1574,7 +1586,7 @@ func testSearchTermsWithUnderscores(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
|
|
|
|
|
t.Run("Search for terms with underscores", func(t *testing.T) {
|
|
|
|
|
params := &model.SearchParams{Terms: "with_underscores_term"}
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20)
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.Nil(t, apperr)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
@@ -1583,7 +1595,7 @@ func testSearchTermsWithUnderscores(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, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20)
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.Nil(t, apperr)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
@@ -1592,7 +1604,7 @@ func testSearchTermsWithUnderscores(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, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20)
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.Nil(t, apperr)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
@@ -1601,7 +1613,7 @@ func testSearchTermsWithUnderscores(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, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20)
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.Nil(t, apperr)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 2)
|
|
|
|
|
@@ -1623,7 +1635,7 @@ func testSearchBotAccountsPosts(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
defer th.deleteUserPosts(bot.UserId)
|
|
|
|
|
|
|
|
|
|
params := &model.SearchParams{Terms: "bot"}
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20)
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.Nil(t, apperr)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 2)
|
|
|
|
|
@@ -1642,7 +1654,7 @@ func testSupportStemmingAndWildcards(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
|
|
|
|
|
t.Run("Should stem appr", func(t *testing.T) {
|
|
|
|
|
params := &model.SearchParams{Terms: "appr*"}
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20)
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.Nil(t, apperr)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 3)
|
|
|
|
|
@@ -1653,7 +1665,7 @@ func testSupportStemmingAndWildcards(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
|
|
|
|
|
t.Run("Should stem approve", func(t *testing.T) {
|
|
|
|
|
params := &model.SearchParams{Terms: "approve*"}
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20)
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.Nil(t, apperr)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
@@ -1670,7 +1682,7 @@ func testSupportWildcardOutsideQuotes(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
|
|
|
|
|
t.Run("Should return results without quotes", func(t *testing.T) {
|
|
|
|
|
params := &model.SearchParams{Terms: "hell*"}
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20)
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.Nil(t, apperr)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 2)
|
|
|
|
|
@@ -1680,7 +1692,7 @@ func testSupportWildcardOutsideQuotes(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
|
|
|
|
|
t.Run("Should return just one result with quotes", func(t *testing.T) {
|
|
|
|
|
params := &model.SearchParams{Terms: "\"hell\"*"}
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20)
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.Nil(t, apperr)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
@@ -1699,7 +1711,7 @@ func testHashtagSearchShouldSupportThreeOrMoreCharacters(t *testing.T, th *Searc
|
|
|
|
|
defer th.deleteUserPosts(th.User.Id)
|
|
|
|
|
|
|
|
|
|
params := &model.SearchParams{Terms: "#123", IsHashtag: true}
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20)
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.Nil(t, apperr)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
@@ -1712,21 +1724,21 @@ func testSlashShouldNotBeCharSeparator(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
defer th.deleteUserPosts(th.User.Id)
|
|
|
|
|
|
|
|
|
|
params := &model.SearchParams{Terms: "gamma"}
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20)
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.Nil(t, apperr)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
th.checkPostInSearchResults(t, p1.Id, results.Posts)
|
|
|
|
|
|
|
|
|
|
params = &model.SearchParams{Terms: "beta"}
|
|
|
|
|
results, apperr = th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20)
|
|
|
|
|
results, apperr = th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.Nil(t, apperr)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
th.checkPostInSearchResults(t, p1.Id, results.Posts)
|
|
|
|
|
|
|
|
|
|
params = &model.SearchParams{Terms: "alpha"}
|
|
|
|
|
results, apperr = th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20)
|
|
|
|
|
results, apperr = th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.Nil(t, apperr)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
@@ -1741,7 +1753,7 @@ func testSearchEmailsWithoutQuotes(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
defer th.deleteUserPosts(th.User.Id)
|
|
|
|
|
|
|
|
|
|
params := &model.SearchParams{Terms: "test@test.com"}
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20)
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.Nil(t, apperr)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
@@ -1756,7 +1768,7 @@ func testSupportSearchInComments(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
defer th.deleteUserPosts(th.User.Id)
|
|
|
|
|
|
|
|
|
|
params := &model.SearchParams{Terms: "reply"}
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20)
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.Nil(t, apperr)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
@@ -1769,7 +1781,7 @@ func testSupportSearchTermsWithinLinks(t *testing.T, th *SearchTestHelper) {
|
|
|
|
|
defer th.deleteUserPosts(th.User.Id)
|
|
|
|
|
|
|
|
|
|
params := &model.SearchParams{Terms: "wikipedia"}
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20)
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.Nil(t, apperr)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 1)
|
|
|
|
|
@@ -1782,7 +1794,7 @@ func testShouldNotReturnLinksEmbeddedInMarkdown(t *testing.T, th *SearchTestHelp
|
|
|
|
|
defer th.deleteUserPosts(th.User.Id)
|
|
|
|
|
|
|
|
|
|
params := &model.SearchParams{Terms: "wikipedia"}
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20)
|
|
|
|
|
results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20)
|
|
|
|
|
require.Nil(t, apperr)
|
|
|
|
|
|
|
|
|
|
require.Len(t, results.Posts, 0)
|
|
|
|
|
|